diff --git a/src/App.vue b/src/App.vue index f7b139d5d0f984ceb4576f77b9007d2766d9d446..b18edfa556d4ebcc357fbcb0d6ad01b19e3598d6 100644 --- a/src/App.vue +++ b/src/App.vue @@ -2,24 +2,30 @@
+ --> + +
\ No newline at end of file diff --git a/src/components/ComputedAndWatch.vue b/src/components/ComputedAndWatch.vue index 9bda6f049f69500b6109e43d40ef750be6505712..ef10cf156fbec750a2816e261675f5ff65b51309 100644 --- a/src/components/ComputedAndWatch.vue +++ b/src/components/ComputedAndWatch.vue @@ -13,7 +13,11 @@

分割线

@@ -28,11 +32,34 @@ export default { }; }, computed: { - fullName: { + fullName0: { get() { return this.firstName + "·" + this.lastName; }, }, + fullName1: { + get() { + return this.firstName + "·" + this.lastName; + }, + set(value) { + console.log("fullName1-setter,${value}"); + let names = value.split("·"); + this.firstName = names[0]; + this.lastName = names[1]; + }, + }, + }, + watch: { + fullName2: { + firstName(val) { + console.log("Watch firstName :${val}"); + this.firstName = val + "·" + this.lastName; + }, + lastName(val) { + console.log("Watch lastName :${val}"); + this.lastName = this.firstName + val; + }, + }, }, }; diff --git a/src/components/IfandShow.vue b/src/components/IfandShow.vue new file mode 100644 index 0000000000000000000000000000000000000000..07f1051f69869955a56dc43c52e6f1e99bba6418 --- /dev/null +++ b/src/components/IfandShow.vue @@ -0,0 +1,42 @@ + + + + +