parent
3133f09bd2
commit
41cacb3eaf
6 changed files with 106 additions and 32 deletions
@ -0,0 +1,13 @@ |
||||
<template> |
||||
<Demo/> |
||||
</template> |
||||
|
||||
<script> |
||||
import {reactive} from "vue"; |
||||
import Demo from "@/components/demo.vue"; |
||||
|
||||
export default { |
||||
name: 'App', |
||||
components: {Demo}, |
||||
} |
||||
</script> |
After Width: | Height: | Size: 6.7 KiB |
@ -0,0 +1,50 @@ |
||||
<template> |
||||
<h1>个人信息:</h1> |
||||
姓:<input type="text" v-model="person.firstName"> |
||||
<br> |
||||
名:<input type="text" v-model="person.lastName"> |
||||
<br> |
||||
<span>全名: {{person.fullName}}</span> |
||||
<br> |
||||
全名:<input type="text" v-model="person.fullName"> |
||||
</template> |
||||
|
||||
<script> |
||||
import {reactive, computed} from "vue"; |
||||
|
||||
export default { |
||||
name: 'Demo', |
||||
// computed:{ |
||||
// fullName() { |
||||
// return this.person.firstName+'-'+this.person.lastName |
||||
// } |
||||
// }, |
||||
setup() { |
||||
let person = reactive({ |
||||
firstName: '张', |
||||
lastName: '三' |
||||
}) |
||||
// 计算属性简写-只读 |
||||
person.fullName = computed(()=>{ |
||||
return person.firstName + '-' + person.lastName |
||||
}) |
||||
|
||||
// 计算属性简写-只读 |
||||
person.fullName = computed({ |
||||
get() { |
||||
return person.firstName + '-' + person.lastName |
||||
}, |
||||
set(val) { |
||||
const nameArr = val.split('-') |
||||
person.firstName = nameArr[0] |
||||
person.lastName = nameArr[1] |
||||
|
||||
} |
||||
}) |
||||
|
||||
return { |
||||
person, |
||||
} |
||||
} |
||||
} |
||||
</script> |
@ -0,0 +1,10 @@ |
||||
// 引入的不再是Vue构造函数, 引入的是一个名为createApp的工厂函数
|
||||
import { createApp } from 'vue' |
||||
import App from './App.vue' |
||||
|
||||
// createApp(App).mount('#app')
|
||||
|
||||
// 创建应用实例对象
|
||||
const app = createApp(App) |
||||
console.log('@@@',app) |
||||
app.mount('#app') |
Loading…
Reference in new issue