ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、视频、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## 1.v-for ~~~ <div id="app" > <template v-for="item of arr"> <div>{{item}}</div> </template> </div> //js var app = new Vue({ el: "#app", data: { arr: [1,2,3] } }) ~~~ ## 2.实现一个简单的todolist ~~~ <div id="app" > <input type="text" v-model="value"> <button @click="handleClick">添加</button> <template v-for="item of arr"> <div>{{item}}</div> </template> </div> ~~~ ~~~ //js var app = new Vue({ el: "#app", data: { arr: [], value:'' }, methods:{ handleClick:function(){ var value = this.value; if(!this.arr.includes(value) && this.value!=""){ this.arr.push(value) } } } }) ~~~