Vue常用指令v-on:click
<!DOCTYPE html><html><head><meta charset="utf-8"><title></title><script src="../js/Vue.js" charset="utf-8"></script><script type="text/javascript">window.onload = functio
·
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="../js/Vue.js" charset="utf-8"></script>
<script type="text/javascript">
window.onload = function(){
var vm = new Vue({
el:'.box',
data:{
arr:['app','orange','pare'],
json:{a:'app',b:'banana',c:'ccc',d:'dog'}
},
methods:{
show:function(){
alert(1);
}
}
});
}
</script>
</head>
<body>
<div class="box">
<ul>
<li v-for='(value,index) in arr'>{{value}} {{index}}</li>
</ul>
<hr />
<ul>
<li v-for='(value,index) in json'>{{value}} {{index}}</li>
</ul>
<hr />
<ul>
<li v-for='(k,v,index) in json'>{{k}} {{v}} {{index}}</li>
</ul>
<hr />
<button type="button" v-on:click='show()'>点击</button>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="../js/Vue.js" charset="utf-8"></script>
<script type="text/javascript">
window.onload = function(){
var vm = new Vue({
el:'.box',
data:{
arr:['app','orange','pare'],
},
methods:{
show:function(){
this.arr.push('tomato');
}
}
});
}
</script>
</head>
<body>
<div class="box">
<button type="button" v-on:click='show()'>点击</button>
<hr />
<ul>
<li v-for='(value,index) in arr'>{{value}} {{index}}</li>
</ul>
</div>
</body>
</html>
更多推荐
已为社区贡献11条内容
所有评论(0)