<!DOCTYPE html>
<body>
<div id="app">
<h1>Yes!</h1>
<span><h1>Age: </h1><h1 v-if="age>20">{{ age }}</h1></span>
<h1>Yes!</h1>
</div>
<script src="https://unpkg.com/vue@next"></script>
<script>
const vm = Vue.createApp({
data() {
return {
age: 28
}
}
}).mount('#app')
</script>
</body>
</html>
为啥不对
<!DOCTYPE html>
<body>
<div id="app">
<h1>Yes!</h1>
<h1>Age: </h1><h1 v-if="age>20">{{ age }}</h1>
<h1>{{ name }}</h1>
</div>
<script src="https://unpkg.com/vue@next"></script>
<script>
const vm = Vue.createApp({
data() {
return {
age: 28
name: Will Smith
}
}
}).mount('#app')
</script>
</body>
</html>
又加了
<!DOCTYPE html>
<body>
<div id="app">
<h1>Yes!</h1>
<h1>Age: </h1>
<h1 v-if="age>20">{{ age }}</h1>
<h1>{{ name }}</h1>
<p>username: <input type="text"></p>
<p>password: <input type="text"></p>
<button>登录</button>
</div>
<script src="https://unpkg.com/vue@next"></script>
<script>
const vm = Vue.createApp({
data() {
return {
age: 28,
name: Will Smith
}
}
}).mount('#app')
</script>
</body>
</html>
yes又不见了
<!DOCTYPE html>
<body>
<div id="app">
<h1 v-if="yes">Yes!</h1>
<h1 v-if="no">No!</h1>
<h1 v-if="age > 20">Age: {{ age }}</h1>
<h1>{{ name }}</h1>
<p>username: <input type="text"></p>
<p>password: <input type="text"></p>
<button>登录</button>
</div>
<script src="https://unpkg.com/vue@next"></script>
<script>
const vm = Vue.createApp({
data() {
return {
age: 28,
}
}
}).mount('#app')
</script>
</body>
</html>
改正了,但是为什么return这里直接加name不行
<!DOCTYPE html>
<body>
<div id="app">
<h1 v-if="yes">Yes!</h1>
<h1 v-if="no">No!</h1>
<h1 v-if="age > 20">Age: {{ age }}</h1>
<h1>{{ name }}</h1>
<p>username: <input type="text"></p>
<p>password: <input type="text"></p>
<button>登录</button>
</div>
<script src="https://unpkg.com/vue@next"></script>
<script>
const vm = Vue.createApp({
data() {
return {
yes: true,
no: false,
age: 28,
}
}
}).mount('#app')
</script>
</body>
</html>
这个name是怎么改的
<!DOCTYPE html>
<body>
<div id="app">
<h1 v-if="yes">Yes!</h1>
<h1 v-if="no">No!</h1>
<h1 v-if="age > 20">Age: {{ age }}</h1>
<h1>Name: {{ name }}</h1>
<p>username: <input type="text" usename="name"></p>
<p>password: <input type="text"></p>
<button>登录</button>
</div>
<script src="https://unpkg.com/vue@next"></script>
<script>
const vm = Vue.createApp({
data() {
return {
yes: true,
no: false,
age: 28,
name: Will Smith,
}
}
}).mount('#app')
</script>
</body>
</html>