Vue中 v-for的用法,获取
<!DOCTYPE html><html><head><meta charset="utf-8" /><script src="https://cdn.bootcss.com/vue/2.5.18-beta.0/vue.js"&
·
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="https://cdn.bootcss.com/vue/2.5.18-beta.0/vue.js"></script>
<title>v-for</title>
<style>
</style>
</head>
<body>
<div id="app">
<div>
<input type="text" placeholder="在这里输入" v-model="val" />
<button @click="sub">点击提交</button>
</div>
<div>
<ul>
<li v-for="(item,index) in list" :key="index">{{item}}</li>
</ul>
</div>
</div>
</body>
<script>
new Vue({
el:"#app",
data:{
val:"",
list:[]
},
methods:{
sub(){
this.list.push(this.val)
this.val=''
}
}
})
</script>
</html>
更多推荐
已为社区贡献1条内容
所有评论(0)