我是靠谱客的博主 自由曲奇,这篇文章主要介绍vue3.0路由安装及组合api,现在分享给大家,希望可以做个参考。

1.安装vue-ruter npm install vue-router@next --save
2.创建router/index文件
import { createRouter,createWebHashHistory} from ‘vue-router’
const router = createRouter({
history: createWebHashHistory(),
routes: [
{
path: ‘/’,
component: () => import(’@/page/index.vue’)
},
{
path: ‘/compositionAPI’,
component: () => import(’@/components/compositionAPI.vue’)
},
{
path: ‘/HelloWorld’,
component: () => import(’@/components/HelloWorld.vue’)

复制代码
1
2
3
} ]

})
export default router

3.main.js文件写入
import router from ‘./router’

createApp(App).use(router).mount(’#app’)

组合api https://segmentfault.com/a/1190000023340641

最后

以上就是自由曲奇最近收集整理的关于vue3.0路由安装及组合api的全部内容,更多相关vue3内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(78)

评论列表共有 0 条评论

立即
投稿
返回
顶部