<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
</head>
<body>
<div id="app">
<p>{{message}}</p>
</div>
<script>
new Vue({
el: '#app',
data: {
message: 'hello Vue'
}
})
</script><hr>
<div id="app1">
<p>{{msg}}</p>
<p v-once>{{msg}}</p>
</div>
<script>
const app = new Vue({
el:'#app1',
data:{
msg:'hello'
}
})
app.msg = 'hahaha';
</script><hr>
<div id="app2">
<p v-text="msg"></p>
</div>
<script>
const app2 = new Vue({
el:'#app2',
data: {
msg:'hello'
}
})
</script><hr>
<div id="app3">
<div v-html="message"></div>
<div v-html='url'></div>
</div>
<script>
new Vue({
el: '#app3',
data: {
message: '<h1>菜鸟教程</h1>',
url:'<a href="https://www.baidu.com/">百度一下</a>'
}
})
</script><hr>
<div id="app4">
<p v-pre>{{msg}}</p>
</div>
<script>
const app4 = new Vue({
el:'#app4',
data:{
msg:'hello'
}
})
</script><hr>
<style>
[v-cloak]{display: none;}
</style>
<div id="app5">
<p v-cloak>{{msg}}</p>
</div>
<script>
setTimeout(()=>{
const app5 = new Vue({
el:'#app5',
data:{
msg:'hello'
}
})
},2000)
</script><hr>
<style>
.key1{color: aqua;}
.key2{font-size: 20px;}
</style>
<div id="app7">
<img v-bind:src="imgURL">
<a :href="bdURL">百度一下</a>
<div :class="{key1:iskey1 , key2:iskey2}">{{msg}}</div>
<button v-on:click='btnClick'>click</button>
</div>
<script>
new Vue({
el: '#app7',
data: {
imgURL:'https://www.runoob.com/images/pulpit.jpg',
bdURL:'https://www.baidu.com/',
msg:'hello',
iskey1:true,
iskey2:true
},
methods:{
btnClick:function(){
this.iskey1 = !this.iskey1;
this.iskey2 = !this.iskey2;
}
}
})
</script><hr>
</body>
</html>