vue項目動態(tài)渲染input,綁定的參數(shù)不實時更新問題
vue動態(tài)渲染input,綁定的參數(shù)不實時更新
遇到過一個問題 按照需求 需要根據(jù)后端返回的list 渲染選項并將輸入的參數(shù)回傳
但是渲染后發(fā)現(xiàn)在輸入框輸入時 輸入框中沒有內容 數(shù)據(jù)沒有進行更新

在input中加一句 刷新數(shù)據(jù) 可解決該問題
@input="$forceUpdate()"
<div v-if="doubleChild.lenght!=0&&radio === 1">
<template v-for="( item,index ) in doubleChild" >
<el-form-item :label="item.text" :key="index">
<el-input
@input="$forceUpdate()"
placeholder="請輸入內容"
v-model="item.inputKey">
</el-input>
</el-form-item>
</template>
</div>
vue動態(tài)渲染表格
項目場景
拼團的后臺項目,項目中需要設置參團的sku,也就是所開的這個團是幾人的團,開團的人數(shù)不同,價格也就不同。
所以需要動態(tài)渲染個表格的列,如下圖中2人團價格以及3人團價格表頭
需求描述
當后臺管理員選擇開團的類型后,所關聯(lián)的參團商品設置sku時,會動態(tài)渲染參團類型所對應的價格。
如下圖sku設置。


代碼:
<el-table
ref="multipleTable"
:data="skuTableData"
tooltip-effect="dark"
style="width: 100%"
border
>
<el-table-column prop="id" label="SKU編號" width="120" align="center">
</el-table-column>
<el-table-column
prop="sku_attr_text"
label="規(guī)格"
width="120"
align="center"
>
</el-table-column>
<el-table-column prop="address" label="價格" align="center">
</el-table-column>
<el-table-column prop="stock" label="庫存" align="center">
</el-table-column>
//動態(tài)渲染的表格列
<el-table-column
:label="item.val"
v-for="(item, index) in tableHead"
:key="index"
>
<template scope="scope">
<el-input
size="small"
v-model="scope.row[item.item]"
placeholder="0"
type="number"
></el-input>
</template>
</el-table-column>
</el-table>
tableHead:[
{ val: "2人團價格", item: "target1" },
{ val: "3人團價格", item: "target2" },
] 是個數(shù)組
skuTableData:[
{target1:1},
{target2:2}
]這個是表格的行數(shù)據(jù) 主要就是數(shù)據(jù)對應上
總結
以上為個人經驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
Ubuntu22.04使用nginx部署vue前端項目的詳細教程
這篇文章主要給大家介紹了關于Ubuntu22.04使用nginx部署vue前端項目的詳細教程,使用nginx部署前端項目是一篇非常詳細的教程,旨在幫助初學者使用Nginx來部署前端項目,需要的朋友可以參考下2024-03-03
Vue2實現(xiàn)數(shù)字滾動翻頁效果的示例代碼
這篇文章主要為大家詳細介紹了Vue2如何實現(xiàn)數(shù)字滾動翻頁效果,文中的示例代碼講解詳細,具有一定的借鑒價值,有需要的小伙伴可以參考一下2024-03-03

