实验一:
<!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">
请输入1-10:<input type="text" v-model="type">
<div v-if="type>1&&type<10">
true
</div>
<div v-else>
false
</div>
</div>
<script>
new Vue({
el: '#app',
data: {
type:'',
}})
</script>
</body>
</html>
浏览器显示如下:
v-bind实验二
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Vue 测试实例 - 菜鸟教程(runoob.com)</title>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<style>
.active {
width: 100px;
height: 100px;
background: green;
}
.active2 {
width: 100px;
height: 100px;
background: yellow;
}
</style>
</head>
<body>
<div id="app">
<div v-bind:class="{active:isActive, active2:!isActive}"></div