1 2 3 4 5 ··· 8 下一页
摘要: 自定义指令分为两个字情景1.在某一个vue文件里,而不是全局2.在main.ts文件里注册全局的自定义指令vue文件 <script setup> import {ref,onMounted} from 'vue' let n =ref(1) const vFocus={ mounted:(elem 阅读全文
posted @ 2022-12-07 17:47 终究还是避免不了遗憾 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 组合式函数(封装/复用)实例:获取鼠标点击的位置坐标 import {reactive,onBeforeUnmount,onMounted } from 'vue' const getMousePoint = () => { let point = reactive({ x: 0, y: 0, }) 阅读全文
posted @ 2022-12-07 17:05 终究还是避免不了遗憾 阅读(45) 评论(0) 推荐(0) 编辑
摘要: provide与inject作用:实现祖孙组件间的通信实例:父组件 <script setup name="Parent"> import Child from './components/Child.vue' import {reactive,provide} from 'vue' let car 阅读全文
posted @ 2022-12-07 16:17 终究还是避免不了遗憾 阅读(41) 评论(0) 推荐(0) 编辑
摘要: 1.默认插槽父组件 <script setup> import Gategory from './components/Category.vue' import {ref} from 'vue' let foods=ref(['火锅','烧烤','小龙虾']) let games=ref(['LOL 阅读全文
posted @ 2022-12-07 15:31 终究还是避免不了遗憾 阅读(86) 评论(0) 推荐(0) 编辑
摘要: 动画效果 <script setup> import {ref} from 'vue' let name=ref('test') let isShow=ref(true) </script> <template> <button @click="isShow=!isShow">显示/隐藏</butt 阅读全文
posted @ 2022-12-07 11:54 终究还是避免不了遗憾 阅读(12) 评论(0) 推荐(0) 编辑
摘要: 绑定事件(子组件向父组件传参)方式一:School子组件通过props传递方式二:Student子组件通过自定义事件传递父组件代码 <script setup> import Student from './components/Student.vue' import School from './ 阅读全文
posted @ 2022-12-07 11:52 终究还是避免不了遗憾 阅读(20) 评论(0) 推荐(0) 编辑
摘要: 实例App.vue文件 <script setup> import Student from './components/Student.vue' import {ref} from 'vue' let address=ref('上海') </script> <template> <div> <St 阅读全文
posted @ 2022-12-07 11:48 终究还是避免不了遗憾 阅读(30) 评论(0) 推荐(0) 编辑
摘要: pinia的优点1.vue3、vue2、都支持2.抛弃了Mutations的操作,只有state、getters和actions3.不需要嵌套模块,符合vue3的Composition api4.完整的typescript支持5.代码更加简洁 挂载pinia在main.ts import { cre 阅读全文
posted @ 2022-12-06 13:35 终究还是避免不了遗憾 阅读(305) 评论(0) 推荐(0) 编辑
摘要: 路由 1.路由就是一组key-value的对应关系(key为路径,value可能是function或component) 2.多个路由,需要经过路由器管理 SPA(single page web application)应用 单页面Web应用:整个页面只有一个完整的页面 点击页面中的导航链接不会刷新 阅读全文
posted @ 2022-12-06 09:27 终究还是避免不了遗憾 阅读(94) 评论(0) 推荐(0) 编辑
摘要: 收集表单数据: 若<input type="text">,则v-model收集的是value值,用户输入的就是value值 若<input type="radio">,则v-model收集的是value值,且要给标签配置value值 若<input type="checkbox"> 没有配置inpu 阅读全文
posted @ 2022-12-05 10:47 终究还是避免不了遗憾 阅读(29) 评论(0) 推荐(0) 编辑
1 2 3 4 5 ··· 8 下一页