【发布时间】:2019-09-13 09:38:53
【问题描述】:
vuejs 2.x.
我有a.html,看起来像:
<div class="form-group col-md-4" v-for="ec in eb.ecustomerList">
<label >{{ec.customerTypeName}}</label>
<div class="form-inline">
<input type="text" class="form-control customerSearchInput" v-bind:id="ec.customerTypeName"
style="width: 20%">
<i class="fas fa-search fa-lg customerSearchIcon" style="color: blue" ></i>
<input type="hidden" v-bind:id="ec.customerTypeName+'Id'" v-model="ec.customerId" />
<input type="hidden" v-model="ec.customerType" value="3" />
</div>
<textarea id="shipperText" v-model="ec.customerDetail"></textarea>
</div>
<div id="bHtml"></div>
v-model="ec.customerId" 必须设置在b.html 中,例如
function selectCustomer(id, item) {
$("#"+id).val(item.name);
$("#"+id+"Id").val(item.id);
$("#"+id+"Text").val(item.otherName);
//need to update value of v-model="ec.customerId" here
}
并且b.html 将加载到<div id="bHtml"></div> 的a.html。
由于某些原因,我无法将selectCustomer(id, item) 添加到 vue 实例中。
那么在这种情况下,如何在js函数中更新vue模型的列表项呢?
【问题讨论】:
标签: javascript vue.js vuejs2