上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 97 下一页
摘要: 一、注意: 一般父传子,子传父也可以,但是太麻烦,一般子传父,用自定义组件 二、使用 1、发送(父组件) <Student :age="19"/> 2、接收(子组件) defineProps(['age']) 阅读全文
posted @ 2025-03-17 19:27 市丸银 阅读(9) 评论(0) 推荐(0)
摘要: 一、安装 npm install pinia 二、构建(main.ts) 1、引入 2、生成 3、使用 import { createApp } from 'vue' import App from './App.vue' import router from '@/router' // 1.引入 阅读全文
posted @ 2025-03-16 21:37 市丸银 阅读(126) 评论(0) 推荐(0)
摘要: 一、区别 1、获取路由器 let router = useRouter() 2、使用 router.push({ name:'detail', query:news }) 二、案例 <template> <ul> <button v-for="news in newList" :key="news. 阅读全文
posted @ 2025-03-16 19:40 市丸银 阅读(41) 评论(0) 推荐(0)
摘要: 一、params简写 1、路由 props: true 注意:只能params传参可以使用 { name:'detail', path:'detail/:id/:name/:content?', component:()=>import('@/views/Detail.vue'), props: t 阅读全文
posted @ 2025-03-16 19:18 市丸银 阅读(58) 评论(0) 推荐(0)
摘要: 一、区别 let route = useRoute() 注意: 1、params参数可选可不选,参数占位后面+? 2、path占位符 3、使用name 二、案例 1、跳转 <template> <ul> <RouterLink :to="{ name:'detail', params: news } 阅读全文
posted @ 2025-03-16 18:56 市丸银 阅读(81) 评论(0) 推荐(0)
摘要: 一、区别 没有 this.route let route = userRoute() route 相当于 this.route 二、路由 <template> <ul> <RouterLink :to="{ path:'/news/detail', query:news }" v-for="news 阅读全文
posted @ 2025-03-16 18:41 市丸银 阅读(73) 评论(0) 推荐(0)
摘要: 一、安装 npm i vue-router 二、创建 1、新建 src/router/index.ts index.ts import {createRouter, createWebHashHistory} from 'vue-router' // 配置路由 const router = crea 阅读全文
posted @ 2025-03-15 17:16 市丸银 阅读(43) 评论(0) 推荐(0)
摘要: 作用:功能分开 1、创建 src/hooks/useSum.ts 2、uesSum.ts文件 import { onMounted, ref } from 'vue'; // 属性、方法写在一个函数里 export default ()=>{ let num = ref(0) function ad 阅读全文
posted @ 2025-03-15 16:40 市丸银 阅读(26) 评论(0) 推荐(0)
摘要: 父传子 父组件 <template> <Person :age="age" /> </template> <script lang="ts" setup name="App"> import { ref } from 'vue'; import Person from './components/P 阅读全文
posted @ 2025-03-15 15:50 市丸银 阅读(12) 评论(0) 推荐(0)
摘要: 使用 <div ref="test"></div> import {ref} ... let test=ref() 子组件传值 父组件 子组件 <template> </template> <script lang="ts" setup name="Person"> import { reactiv 阅读全文
posted @ 2025-03-15 14:55 市丸银 阅读(8) 评论(0) 推荐(0)
上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 97 下一页