data绑定的值和双括号{{}}中的值保持一致
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>测试案例</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.js!'
}
})
</script>
</body>
</html>
v-html的使用
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>测试案例v-html</title>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
</head>
<body>
<div id="app">
<div v-html="message"></div>
</div>
<script>
new Vue({
el:'#app',
data:{
message:'<h1>1234</h1> <p>好 '
}
})
</script>
</body>
</html>
true or false判断语句
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>测试实例</title>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
</head>
<body>
<div id='app'>
<p v-if="seen">现在看到我了</p>
<template v-if="ok">
<h1>1232</h1>
<p>学的是梦想</p>
</template>
</div>
<script>
new Vue({
el:'#app',
data:{
seen:true,
ok:true
}
})
</script>
</body>
</html>
v-if判断
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>简单的if</title>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
</head>
<body>
<div id="app">
<div v-if="Math.random()>0.5">
Sorry
</div>
<div v-else>
Not Sorry
</div>
</div>
<script>
new Vue({
el:'#app'
})
</script>
</body>
</html>