0
根據商務部,如何在自定義組件中使用v-bind?
<input v-model="something">
是一樣的:
<input
v-bind:value="something"
v-on:input="something = $event.target.value">
,所以我嘗試以下,它的工作原理:
<input v-model='sample'>
<input v-bind:value='sample' v-on:input="sample = $event.target.value" >
現在,當我想在一個自定義組件相同,它會觸發一個錯誤:
VM99:2Uncaught TypeError: Cannot read property 'value' of undefined
我在這裏錯過了什麼讓它工作?謝謝。
感謝v-bind的工作,但v模型不在小提琴 – AngeloC
@AngeloC請檢查更新的小提琴,在您的模板中您也期待'$ event.target.value'。 –
小提琴的作品,謝謝。但我只是想知道爲什麼'myinput'不能像'input'一樣工作 – AngeloC