运行不了,试了好几遍。哪里出问题了?
来源:2-7 使用组件改造TodoList
kiterumer
2018-08-01
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>todolist</title>
<script src="./vue.js"></script>
</head>
<body>
<div id="root">
<input type="text" v-model="todoValue" />
<button @click="handleBtnClick">提交</button>
</div>
<ul>
<todo-item v-bind:content="item"
v-for="item in list">
</todo-item>
</ul>
<script>
// Vue.component("TodoItem",{
// props:['content'],
// template:"<li>{{content}}</li>",
// })
var TodoItem={
props:['content'],
template:"<li>{{content}}</li>"
}
var app = new Vue({
el:"#root",
components:{
TodoItem: TodoItem
},
data:{
todoValue:"",
list:[]
},
methods:{
handleBtnClick:function(){
// alert(this.inputValue);
this.list.push(this.todoValue);
this.todoValue='';
}
}
})
</script>
</body>
</html>
2回答
-
幕布斯3709169
2018-08-07
把UL写在div里面
00 -
kiterumer
提问者
2018-08-01
发现问题了,div标签没闭合。ε=(´ο`*)))
00
相似问题