脚手架中使用路由
安装路由
cnpm install vue-router@4
src下创建router.ts
// @ts-nocheck
import { createRouter, createWebHistory } from 'vue-router'
import index from './components/index.vue'
import goods from "./components/goods.vue"
// 创建路由实例对象
const router = createRouter({
history: createWebHistory(),
routes: [
{ path: '/', name:'index',component:index },
{ path: '/goods', name:'goods',component:goods }
],
})
export default router
修改main.ts
import { createApp } from 'vue'
import App f