摘要:
自定义指令分为两个字情景1.在某一个vue文件里,而不是全局2.在main.ts文件里注册全局的自定义指令vue文件 <script setup> import {ref,onMounted} from 'vue' let n =ref(1) const vFocus={ mounted:(elem 阅读全文
摘要:
组合式函数(封装/复用)实例:获取鼠标点击的位置坐标 import {reactive,onBeforeUnmount,onMounted } from 'vue' const getMousePoint = () => { let point = reactive({ x: 0, y: 0, }) 阅读全文
摘要:
provide与inject作用:实现祖孙组件间的通信实例:父组件 <script setup name="Parent"> import Child from './components/Child.vue' import {reactive,provide} from 'vue' let car 阅读全文
摘要:
1.默认插槽父组件 <script setup> import Gategory from './components/Category.vue' import {ref} from 'vue' let foods=ref(['火锅','烧烤','小龙虾']) let games=ref(['LOL 阅读全文
摘要:
动画效果 <script setup> import {ref} from 'vue' let name=ref('test') let isShow=ref(true) </script> <template> <button @click="isShow=!isShow">显示/隐藏</butt 阅读全文
摘要:
绑定事件(子组件向父组件传参)方式一:School子组件通过props传递方式二:Student子组件通过自定义事件传递父组件代码 <script setup> import Student from './components/Student.vue' import School from './ 阅读全文
摘要:
实例App.vue文件 <script setup> import Student from './components/Student.vue' import {ref} from 'vue' let address=ref('上海') </script> <template> <div> <St 阅读全文