0
我使用的部件事先鍵入的內容從VUE錶帶,VueJS 2鍵盤緩衝回調方法
我試圖做一個回調,我打將在其上的數據戳在我的文字輸入後選擇。
一旦我打回車,inventoryName和inventoryId被成功加蓋,但inventoryCode組件被重置。
如何防止它重置或我做錯了什麼?正如我從console.log中看到的那樣,它具有價值。
<typeahead v-model="inventoryCode" placeholder="Inventory code..." async="{{url('api/inventory')}}/" :template="inventorySearch" :on-hit="inventoryCallBack"></typeahead>
<input type="text" name="inventory_name" id="inventory_name" class="form-control" v-model="inventoryName" readonly />
new Vue({
el: '#app',
components:{Typeahead},
data: {
'inventoryCode': '',
'inventoryName': '',
'inventoryId': '',
'inventorySearch': '<div style="min-width:150px;"><b>@{{item.inventory_name}}</b></div><div>@{{item.inventory_code}}</div><div>@{{item.inventory_short_desc}}</div>'
},
methods:{
inventoryCallBack: function(item){
console.log(item.inventory_code);
this.inventoryCode = item.inventory_code;
this.inventoryName = item.inventory_name;
this.inventoryId = item.id;
console.log(this.inventoryCode);
},
}
});
首先'inventoryCallBack'函數應該在方法屬性中。 –
@SrinivasDamam對不起,錯字,它是一種方法支柱。其他模型正在分配值,但不是inventoryCode。 –
你在'components:{Typeahead}'中有一個大寫「T」。它不應該是小寫嗎? – redshift