<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>双向数据绑定和事件绑定</title>
</head>
<body>
<div id="app">
<p>{{msg}}</p>
<input v-model="msg">
<button onclick="alert('msg='+vm.msg)">点我看看1</button>
<button v-on:click="alert('msg='+this.msg)">点我看看2</button>
<button v-on:click="handleClick">点我看看3</button>
</div>
<script src="./libs/vue.js"></script>
<script type="text/javascript">
var vm = new Vue({
el:"#app",
data:{
msg:'Hello,How are you?'
},
methods:{
handleClick:function(){
alert('msg='+this.msg)
}
}
})
</script>
</body>
</html>
上面代码,只有这一句<button v-on:click="alert('msg='+this.msg)">点我看看2</button> 总是报错,不知道为什么?谢谢回答
橋本奈奈未
相关分类