我的數(shù)據(jù)雙向綁定報(bào)錯(cuò),不知道為什么,第一次輸入數(shù)據(jù)時(shí)可以正常提交,列表里也會(huì)有數(shù)據(jù),后面再輸入提交就是空白
<template>
<div>
? <div>
? ? <input v-modal="inputValue">
? ? <button @click="handleSubmit">提交</button>
? </div>
? <ul>
? <todo-item v-for="(item, index) of list" :content="item"></todo-item>
? </ul>
?
?</div>
</template>
<script>
import TodoItem from './components/TodoItem'
??
export default {
components:{
'todo-item': TodoItem,
},
data () {
? return {
? inputValue: '123',
? list: []
? }
? },
? methods:{
? handleSubmit (){
? this.list.push(this.inputValue);
? console.log(this.list)
? this.inputValue = '';
? }
? }
}
</script>
下面是todoitem模塊的代碼
<template>
? <li>{{content}}</li>
</template>
<script>
export default {
? props: ['content']
}
??
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>
2018-09-28