猿问

VUE如何为生成元素绑定变量?

          <div class="classInner" v-for="(item,i) in detailData.goods_param">

            <span class="title width40">{{item.name}}</span>

            <el-input placeholder="请输入内容" class="shortInput" :value="item.value">

            </el-input>

          </div>

这是生成的值。 如何获取修改后的值。或者怎么为循环出的三个input 分别绑定三个变量

慕的地6264312
浏览 685回答 1
1回答

梦里花落0921

你可以为你的input绑定v-modeleg:...<el-input placeholder="请输入内容" class="shortInput" :value="item.value" v-model="inputData[i]"></el-input>...在你的data中新增一个空对象inputData你就可以拿到你文本框的值了。data(){&nbsp; &nbsp; return {&nbsp; &nbsp; &nbsp; &nbsp; ...&nbsp; &nbsp; &nbsp; &nbsp; inputData:{}&nbsp; &nbsp; }}
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答