v-once基本使用
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="app">
<h2>{{message}}</h2>
<h2 v-once>{{message}}</h2>
</div>
<script src="../js/vue.js"></script>
<script>
const app = new Vue({
el: '#app',
data: {
message: 'hello vue'
}
})
</script>
</body>
</html>
v-once:不會隨着數據的改變而改變,只會在第一次的時候展示數據
v-html 基本使用
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="app">
<h2>{{url}}</h2>
<h2 v-html="url">{{url}}</h2>
</div>
<script src="../js/vue.js"></script>
<script>
const app = new Vue({
el: '#app',
data: {
message: 'hello vue',
url: '<a href="https://wwww.baidu.com">百度一下</a>'
}
})
</script>
</body>
</html>
v-html會把HTML代碼轉換爲對應的內容
v-text基本使用
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="app">
<h2>{{message}},兮動人</h2>
<h2 v-text="message">,兮動人</h2>
</div>
<script src="../js/vue.js"></script>
<script>
const app = new Vue({
el: '#app',
data: {
message: 'hello vue'
}
})
</script>
</body>
</html>
v-text會把後面HTML內容給覆蓋掉
v-pre的基本使用
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="app">
<h2>{{message}}</h2>
<h2 v-pre>{{message}}</h2>
</div>
<script src="../js/vue.js"></script>
<script>
const app = new Vue({
el: '#app',
data: {
message: 'hello vue'
}
})
</script>
</body>
</html>
v-pre會原封不動的顯示出所寫的內容,不會解析
v-cloak的基本使用
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
[v-cloak] {
display: none;
}
</style>
</head>
<body>
<div id="app" v-cloak>
{{message}}
</div>
<script src="../js/vue.js"></script>
<script>
//在vue解析之前,div中有一個屬性v-clock
//在vue解析之後,div中沒有一個屬性v-clock
setTimeout(function () {
const app = new Vue({
el: '#app',
data: {
message: 'hello vue'
}
})
},1000)
</script>
</body>
</html>