|
@@ -0,0 +1,51 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <h1>Demo8</h1>
|
|
|
+ <p>姓:
|
|
|
+ <input type="text" v-model="firstName">
|
|
|
+ </p>
|
|
|
+ <p>名:
|
|
|
+ <input type="text" v-model="lastName">
|
|
|
+ </p>
|
|
|
+ <button @click="setMain">设置</button>
|
|
|
+
|
|
|
+ <h1>全称:{{ firstName + lastName }}</h1>
|
|
|
+ <h1>全称:{{ fullName }}</h1>
|
|
|
+ <h1>全称:{{ fullName }}</h1>
|
|
|
+ <h1>全称:{{ fullName }}</h1>
|
|
|
+ <h1>全称:{{ fullName }}</h1>
|
|
|
+ <h1>全称:{{ fullName }}</h1>
|
|
|
+ <h1>全称:{{ fullName }}</h1>
|
|
|
+ <h1>全称:{{ fullName }}</h1>
|
|
|
+ <h1>全称:{{ fullName }}</h1>
|
|
|
+ <h1>全称:{{ fullName }}</h1>
|
|
|
+ <h1>全称:{{ fullName }}</h1>
|
|
|
+ <h1>全称:{{ fullName }}</h1>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script lang="ts" setup>
|
|
|
+import {ref,reactive,computed} from "vue"
|
|
|
+let firstName = ref<string>("");
|
|
|
+let lastName = ref<string>("");
|
|
|
+// let fullName = computed<string>({
|
|
|
+// get() {
|
|
|
+// return firstName.value + lastName.value
|
|
|
+// },
|
|
|
+// set(val:string):void {
|
|
|
+// let [x,y] = val.split('-');
|
|
|
+// firstName.value = x;
|
|
|
+// lastName.value = y;
|
|
|
+
|
|
|
+// }
|
|
|
+// })
|
|
|
+let fullName = computed<string>(()=>{
|
|
|
+ return firstName.value + lastName.value
|
|
|
+})
|
|
|
+// function setMain():void {
|
|
|
+// fullName.value = '糖-果'
|
|
|
+// }
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+</style>
|