<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script src="./vue.js"></script>
</head>
<body>
<div id="root">
<h1 v-text="msg"></h1> <!--转译为text-->
<h1 v-html="m"></h1> <!--不转译-->
<h1 v-text="m"></h1>
<h1 v-on:click="changeMsg">{{msg}}</h1> <!--插入式绑定数据,上面是非插入式-->
</div>
<script>
new Vue({
el:"#root",
data:{
msg:"hello",
m:'<h1>word</h1>'
},
methods:{
changeMsg:function(){ //点击最后的hello/world 会变成world/hello
if(this.msg=='hello'){
this.msg='world'
}
else{
this.msg='hello'
}
}
}
})
</script>
</body>
</html>
VUE(v-text,v-html,v-on:click(@click)的使用)
最新推荐文章于 2024-06-14 11:31:16 发布