vite+vue3,安装router路由
1.npm安装routernpm install vue-router@42.创建views和router目录,router中新建index.js3.index.js中添加内容import { createRouter, createWebHistory } from 'vue-router'import page1 from "../views/tubiao2.vue";const router
·
1.npm安装router
npm install vue-router@4
2.创建views和router目录,router中新建index.js
3.index.js中添加内容
import { createRouter, createWebHistory } from 'vue-router'
import page1 from "../views/tubiao2.vue";
const routerHistory = createWebHistory()
const router = createRouter({
history: routerHistory,
routes: [
{
path: '/',
name:'Login',
component: () => import('../views/login.vue')
},
{
path: '/page1 ',
component: page1
},
]
})
export default router
4.在main.js中引用
import { createApp } from 'vue'
// import * as echarts from 'echarts'
import router from './router'
import './assets/style.css'
import App from './App.vue'
const app = createApp(App)
app.use(router)
// app.config.globalProperties.$echarts = echarts
// app.echarts=echarts
app.mount('#app')
完成
更多推荐
已为社区贡献3条内容
所有评论(0)