添加案例

mac_study
roger 2 years ago
parent 2d43e1539c
commit ebc6b2c321
  1. 25
      08_计算属性/1.姓名案例_插值语法实现.html
  2. 30
      08_计算属性/2.姓名案例_methods实现.html

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>1.姓名案例_插值语法实现</title>
<script type="text/javascript" src="../vue.js"></script>
</head>
<body>
<div id="root">
姓:<input type="text" v-model="firstName"> <br>
名:<input type="text" v-model="lastName"> <br>
姓名: <span>{{firstName}}-{{lastName}}</span>
</div>
<script type="text/javascript">
new Vue({
el: '#root',
data: {
firstName: "张",
lastName: "三"
},
})
</script>
</body>
</html>

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>2.姓名案例_methods实现</title>
<script type="text/javascript" src="../vue.js"></script>
</head>
<body>
<div id="root">
姓:<input type="text" v-model="firstName"> <br>
名:<input type="text" v-model="lastName"> <br>
姓名: <span>{{fullName()}}</span>
</div>
<script type="text/javascript">
new Vue({
el: '#root',
data: {
firstName: "张",
lastName: "三"
},
methods: {
fullName(){
return this.firstName + '-' + this.lastName
}
}
})
</script>
</body>
</html>
Loading…
Cancel
Save