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

npm info vue-router versions

 安装最新的vue-router

yarn add vue-router@4.0.0-beta.10

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");

 

Logo

前往低代码交流专区

更多推荐