vue3配合vue router4使用

使用命令行查看vue-router 所有版本号

npm info vue-router versions

 安装最新的vue-router

yarn add [email protected]

router

// Vue Router 4
import { createRouter, createWebHistory } from "vue-router";
import index from '../views/index.vue'
import one from '../views/one.vue'

export default createRouter({
    history: createWebHistory(),
    routes: [
        {
            path: '/',
            component: index
        },
        {
            path: '/one',
            component: one
        }
    ],
});

main.js

import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import './index.css'

const app = createApp(App);
app.use(router);
app.mount("#app");

 

你可能感兴趣的:(vue,vue3,vue,router4)