<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Document</title><script src="vue.js"></script></head><body><div id = "root"><div><input v-model="inputValue" /><button @click="handlerSubmit">提交</button></div><ul><li v-for="(item,index) of list" :key="index">{{itme}}</li></ul></div><script>new Vue({el:"#root",data: {inputValue:'',list:[1,2,3]},methods: {handlerSubmit: function() {this.list.push(this.inputValue)}}})</script></body></html>
运行测试的时候,正在输入框中输入后显示不出输入内容
妈也,原来是中英文的花括号问题!