parent
2d43e1539c
commit
ebc6b2c321
2 changed files with 55 additions and 0 deletions
@ -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…
Reference in new issue