第一天
- template模板中不需要.value
- const age = ref(100)
- script标签内 age.
value
=99999 - computed
- 里面一个函数
- 里面一个对象 ----> get 和 set
- watch
- 监听多个值[]
- 监听对象 {deep:true , immediate:true}
- 父子组件传值
---father.vue---
<son msg="我是真的帅" :person="person" @sonEvent="getEvent" />
---son.vue---
const props = defineProps({
msg: String,
person: {
type: Object,
default: () => {
name: '玲梦';
age: 19;
}
}
});
---son.vue---
const emits=defineEmits(['sonEvent'])
const send2Parent=() => {
emits('sonEvent',['董卿','明理'])
}
---顶级组件---
provide('money', money);
provide('changeMoney', changeMoney);
---子组件---
const money =inject('money')
const changeMoney =inject('changeMoney')
- ref----toRfefs 使用到时再记