<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
[v-cloak]{
display: none;
}
</style>
</head>
<body>
<div id="app" v-cloak>
<h2 v-once>{{message}},vue</h2>
<h2 v-html='url'></h2>
<h2 v-text='message'>vue</h2>
<!-- v-text會覆蓋 -->
<h2 v-pre>{{message}}</h2>
</div>
<script src="js/vue.js"></script>
<script>
// 在vue解析前,div中有一個屬性v-cloak
// 在vue解析後,div中無屬性v-cloak
const app = new Vue({
el: '#app',
data: {
message:'hello',
url: '<a href="">a</a>'
}
})
</script>
</body>
</html>
v-bind初步:
<div id="app">
<img v-bind:src="imgURL" alt="">
</div>
<script src="js/vue.js">
</script>
<script>
const app = new Vue({
el: '#app',
data: {
imgURL: 'https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=404575795,2376485523&fm=26&gp=0.jpg'
}
})
</script>