运行不了,试了好几遍。哪里出问题了?

来源: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里面

0
0

kiterumer

提问者

2018-08-01

发现问题了,div标签没闭合。ε=(´ο`*)))

0
0

Vue2.5-2.6-3.0开发去哪儿网App 零基础入门到实战

课程紧跟Vue3版本迭代,企业主流版本Vue2+Vue3全掌握

10733 学习 · 8206 问题

查看课程