You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
714 B
37 lines
714 B
2 years ago
|
<template>
|
||
|
<h1>个人信息:</h1>
|
||
|
<h2>姓名:{{ person.name }}</h2>
|
||
|
<h2>年龄:{{ person.age }}</h2>
|
||
|
<button @click="test">触发showHelloMsg</button>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
import {reactive} from "vue";
|
||
|
|
||
|
export default {
|
||
|
name: 'Demo',
|
||
|
beforeCreate() {
|
||
|
console.log('---beforeCreate---')
|
||
|
},
|
||
|
props: ['msg', 'user'],
|
||
|
emits: ['hello'],
|
||
|
setup(props, context) {
|
||
|
console.log('---setup---', context) // $attrs $emits $slots
|
||
|
console.log('---setup---', context.slots) // $attrs $emits $slots
|
||
|
let person = reactive({
|
||
|
name: '张三',
|
||
|
age: 18
|
||
|
})
|
||
|
|
||
|
function test() {
|
||
|
context.emit('hello',666)
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
person,
|
||
|
test
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
</script>
|