1.vue-html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div id='app'>
<input type="text" v-model='msg'>
<p v-html='msg'>{{msg}}</p>
</div>
<script src='vue.js'></script>
<script>
new Vue({
el:'#app',
data:{
msg:'hello'
}
})
</script>
</body>
</html>
效果图示:
2.vue-text
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div id='app'>
<input type="text" v-model='msg'>
<h3 v-text='msg'>{{msg}}</h3>
</div>
<script src='vue.js'></script>
<script>
new Vue({
el:'#app',
data:{
msg:'hello'
}
})
</script>
</body>
</html>
效果图示:
3.vue-once
vue-once
只绑定一次
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div id='app'>
<a href="" v-once>{{msg}}</a>
</div>
<script src='vue.js'></script>
<script>
new Vue({
el:'#app',
data:{
msg:'hello'
}
})
</script>
</body>
</html>
效果图示:
4.vue-pre
vue-pre
原样输出
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div id='app'>
<h1 v-pre>{{msg}}</h1>
</div>
<script src='vue.js'></script>
<script>
new Vue({
el:'#app',
data:{
msg:'hello'
}
})
</script>
</body>
</html>
效果图示:
5.vue-cloak
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
[v-cloak]{
display:none;
}
</style>
</head>
<body>
<div id='app'>
<h1 v-cloak>{{msg}}</h1>
</div>
<script src='vue.js'></script>
<script>
new Vue({
el:'#app',
data:{
msg:'hello vue'
},
beforeMount:function(){
alert('beforeMount')
}
})
</script>
</body>
</html>
效果图示:
点击确定后: