You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
609 B
30 lines
609 B
<!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> |