升级vue3注意事项记录 vue3都需要升级些什么

sass语法的使用

控制台报错:Syntax Error: TypeError: this.getOptions is not a function
原因:版本问题,sass-loader的版本过新,安装10.1.1版本即可解决;

路由跳转问题

路由不跳转:
原因:App.vue中别忘了加上 <router-view></router-view>

//router: index.js
import { createRouter,createWebHashHistory} from "vue-router"'

const home = ()=> import ('../pages/home')
const colorful = ()=> import ('../pages/colorful')
const other = ()=> import('../pages/other')

const routes = [
   {
       path: '/',
       name: 'home',
       component: home
   },
   {
       path: '/colorful',
       name: 'colorful',
       component: colorful
   },
   {
       path: '/other',
       name: 'other',
       component: other
   },
]

const router = createRouter({
   history: createWebHashHistory(),
   routes: routes
})

export default router
// main.js
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'

const app = createApp(App)

app.use(router)
app.mount('#app')
posted @ 2021-08-15 16:46  叶子玉  阅读(374)  评论(0编辑  收藏  举报