Vue 的双向绑定实现组合姓名的欢迎页面
<!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>欢迎页面</title>
<script src="vue.min.js"></script>
<style>
#app{
text-align: center;
padding: 10px;
}
</style>
</head>
<body>
<div id="app">
<fieldset>
<legend>Welcome to you</legend>
<p>
<label for="txtFirstName">姓:</label>
<input type="text" v-model="firstName" id="txtFirstName">
</p>
<p>
<label for="txtLastName">名:</label>
<input type="text" v-model="lastName" id="txtLastName">
</p>
</fieldset>
<p>
欢迎您! {{firstName+lastName}}
</p>
</div>
<script>
var user={
firstName:"",
lastName:""
};
var vm=new Vue({
el:"#app",
data:user
});
</script>
</body>
</html>