摘要: 尚硅谷视频教程 组件的生命周期 创建 挂载 更新 销毁 在特定的时期调用特定的函数,即生命周期 vue2的生命周期 4个周期,对应8个钩子(生命周期函数) 创建:创建前、创建完毕 挂载:挂载前、挂载完毕 更新:更新前、更新完毕 销毁:销毁前、销毁完毕 <script> export default 阅读全文
posted @ 2024-03-21 22:33 ayubene 阅读(18) 评论(0) 推荐(0)
摘要: 官方教程链接 子组件还可以向父组件触发事件 子组件声明触发的事件,并且带参数触发 <script lang="ts" setup> const emit = defineEmits(['res']) emit('res','hi thisismy msg') // 第一个参数是事件名称,其他参数都会 阅读全文
posted @ 2024-03-21 16:13 ayubene 阅读(39) 评论(0) 推荐(0)
摘要: 官方教程链接 子组件可以通过 props 从父组件接受动态数据 首先,需要声明它所接受的 props: const props = defineProps({ msg: String }) 在父组件中传数据 <template> <Props :msg="hiHi"/> </template> <s 阅读全文
posted @ 2024-03-21 15:55 ayubene 阅读(25) 评论(0) 推荐(0)
摘要: 官方教程链接 侦听器: import { ref, watch } from 'vue' const count = ref(0) watch(count, (newCount) => { console.log(`new count is: ${newCount}`) }) pre标签:识别jso 阅读全文
posted @ 2024-03-21 11:52 ayubene 阅读(13) 评论(0) 推荐(0)