|
@@ -0,0 +1,69 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <h1>Demo8</h1>
|
|
|
+ <p>姓:
|
|
|
+ <input type="text" v-model="firstName">
|
|
|
+ <!-- <input type="text" v-model="firstName" @input="handleInp"> -->
|
|
|
+ </p>
|
|
|
+ <p>名:
|
|
|
+ <input type="text" v-model="lastName">
|
|
|
+ </p>
|
|
|
+ <button @click="setMain">设置</button>
|
|
|
+
|
|
|
+ <h1>全称:{{ firstName + lastName }}</h1>
|
|
|
+ <!-- <h1>全称:{{ showMain() }}</h1>
|
|
|
+ <h1>全称:{{ showMain() }}</h1>
|
|
|
+ <h1>全称:{{ showMain() }}</h1>
|
|
|
+ <h1>全称:{{ showMain() }}</h1>
|
|
|
+ <h1>全称:{{ showMain() }}</h1>
|
|
|
+ <h1>全称:{{ showMain() }}</h1>
|
|
|
+ <h1>全称:{{ showMain() }}</h1>
|
|
|
+ <h1>全称:{{ showMain() }}</h1>
|
|
|
+ <h1>全称:{{ showMain() }}</h1>
|
|
|
+ <h1>全称:{{ showMain() }}</h1>
|
|
|
+ <h1>全称:{{ showMain() }}</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("");
|
|
|
+let lastName = ref("");
|
|
|
+let fullName = computed({
|
|
|
+ get() {
|
|
|
+ console.log("你好")
|
|
|
+ return firstName.value + lastName.value
|
|
|
+ },
|
|
|
+ set(val) {
|
|
|
+ console.log("出发",val.split('-'))
|
|
|
+ let [x,y] = val.split('-');
|
|
|
+ firstName.value = x;
|
|
|
+ lastName.value = y;
|
|
|
+
|
|
|
+ }
|
|
|
+})
|
|
|
+// function handleInp(e) {
|
|
|
+// console.log(121,e)
|
|
|
+// }
|
|
|
+function showMain() {
|
|
|
+ console.log("2121")
|
|
|
+ return firstName.value + lastName.value;
|
|
|
+}
|
|
|
+function setMain() {
|
|
|
+ fullName.value = '糖-果'
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+</style>
|