?系列文章目錄
第一篇?Vue3創(chuàng)建項目(一)新手教程
第二篇 Vue3創(chuàng)建項目(二)router路由配置和使用?
第三篇?Vue3創(chuàng)建項目(三)Vuex配置
目錄
?系列文章目錄
?main.js配置,直接看圖,如下:
前言:?
?//main.js 配置 順序依次如下,不能亂?。。?!亂了容易報錯
安裝element-plus命令
安裝路由
?安裝vuex
main.js配置,直接看圖,如下:
前言:?
新手在創(chuàng)建vue3項目的時候,會用到很多配置的地方,會出很多錯,要么就是順序位置錯了,要么就是組件引入錯,依賴錯了,配置錯了,本文主要是講如何配置及安裝,以及避坑指南,我踏過的坑,后面就可以避免了,前人在樹后人乘涼。?
?//main.js 配置 順序依次如下,不能亂?。。?!亂了容易報錯
//main.js 配置 順序依次如下,不能亂!?。?!亂了容易報錯
/***
*
* router 路由
*
* store vuex全局管理
*
* elementplus
*
*/
import { createApp } from 'vue'
import App from './App.vue'
import router from './router/index'
import store from './store/index'
//引入elementplus
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
//引入elementplus icon
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
app.component(key, component)
}
// 使用use將文件掛載上去
createApp(App).use(router).use(store).use(ElementPlus).mount('#app')
?下面是部分安裝命令
安裝element-plus命令
npm install element-plus --save ??
?
?配置element-Icon
npm install @element-plus/icons-vue
//main.js中配置
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
app.component(key, component)
}
app.use(router).use(ElementPlus).mount('#app')
安裝路由
npm install vue-router@4
?安裝vuex
npm install vuex@next --save
最后:
其他的配置,后續(xù)遇到會進行補充更新文章來源:http://www.zghlxwxcb.cn/news/detail-429100.html
覺得有幫助感興趣的話可以關注一下,后面如果有任何建議可以直接留言。文章來源地址http://www.zghlxwxcb.cn/news/detail-429100.html
到了這里,關于Vue3創(chuàng)建項目(四)main.js配置,避坑指南的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!