<template>
<!-- 1.1 2个input -->
<input type="text" v-model="firstName">
<input type="text" v-model="secondName">
<!-- 2.2 触发函数 -->
<input type="button" value="显示" @click="exeName"> <br>
fullName : {{fullName}} <br>
<!-- 3.2 显示结果 -->
fullName2 : {{fullName2}} <br>
</template>
<script>
export default {
data() {
return {
// 1.2 两个变量 + 1个变量
firstName: '',
secondName: '',
fullName: ''
methods: {
// 2.1 声明函数
exeName() {
this.fullName = this.firstName + this.secondName
computed: {
// 3.1 声明计算属性
fullName2() {
// 格式:姓为'张',名为'三',全称为'张三'
return this.firstName + this.secondName
</script>
<style>
</style>