升級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')
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章