企业🤖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) } } } }) ~~~