标签:数据绑定 body rip head v-for index ext push div
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script src="vue.min.js"></script>
</head>
<body>
<div id="app">
<input type="text" v-model="name"/>
<input type="text"v-model="age" />
<button @click="add()">提交</button>
<h1>{{msg}}</h1>
<ul>
<li v-for="(u,index) in obj" :key="index">
{{u.name}} {{u.age}}
</li>
</ul>
</div>
<script type="text/javascript">
new Vue({
el:"#app",
data:{
msg:"123",
name:"默认名称",
age:0,
obj:[
{name:"x", age:1},
{name:"y", age:11},
{name:"z", age:111}
]
},
methods:{
add(){
this.obj.push(
{
name:this.name,
age:this.age,
}
)
}
},
});
</script>
</body>
</html>
标签:数据绑定 body rip head v-for index ext push div
原文地址:https://www.cnblogs.com/weixin2623670713/p/13328391.html