<template>
<el-input
v-for="(item,index) in defaultValue"
:key="index"
v-model="defaultValue[index]"
placeholder="请输入内容"
style="width:80%">
</el-input>
</template>
<script>
export default {
data() {
return {
defaultValue:[]
}
},
created(){
this.getInputValue() // 调用方法
},
methods(){
getInputValue () {
// 假设这是后端返回的值
/*[{
"id": 1,
"defaultValue": "111",
},
{
"id": 2,
"defaultValue": "222",
}],*/
for (var i = 0; i < res.length; i++) { //此时我们遍历res数组
this.defaultValue.push(res[i].defaultValue) // push到defaultValue空数组中
}
}
}
}
</script>
element Ui 动态渲染input V-model的值
于 2022-07-27 17:12:31 首次发布