index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>vue</title>
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.21/dist/vue.js"></script>
</head>
<body>
<div id="app">
<input type="text" v-model='name'>
<span v-show="name">我的名字是:{{name}}</span><br>
<input type="text" v-model='age'>
<span v-if="age">我的年龄是:{{age}}</span>
</div>
<script src="app.js"></script>
</body>
</html>
app.js
var app = new Vue({
el:'#app',
data:{
name:null,
age:null,
}
});
网友评论