Cannot read properties of undefined (reading 'use')
来源:12-1 Vue 3.0环境升级
少年梦i
2022-04-09
Vue3.0环境
Localhost打开报错
// cmd:
// 网页报错:
//main.js:
//package.json:
写回答
2回答
-
覆手为雨
2022-08-07
改3个地方,vue3.x以上必须用新写法
1、src\router\index.js
import { createRouter, createWebHashHistory } from 'vue-router' import Home from '@/pages/home/Home' import Detail from '@/pages/detail/Detail' const routes = [ { path: '/', name: 'Home', component: Home }, { path: '/city', name: 'City', component: () => import('@/pages/city/City') }, { path: '/detail/:id', name: 'Detail', component: Detail } ] const router = createRouter({ history: createWebHashHistory(), routes }) export default router
2、src\main.js
import { createApp } from 'vue' import App from './App.vue' import router from './router' import VueAwesomeSwiper from 'vue-awesome-swiper' import store from './store' import 'styles/reset.css' import 'styles/border.css' import 'styles/iconfont.css' import 'swiper/dist/css/swiper.css' createApp(App).use(router).use(store).use(VueAwesomeSwiper).mount('#app')
3、src\App.vue
<template> <div id="app"> <router-view v-slot="{Component}"> <keep-alive exclude="Detail"> <component :is="Component" /> </keep-alive> </router-view> </div> </template>
00 -
少年梦i
提问者
2022-04-10
求救啊大家
012022-04-17
相似问题