vue+elementui項目打包后樣式變化問題


博主剛剛解決了index.html空白問題,剛打開項目頁面又發現了樣式出現了大問題,樣式與開發版本有很大不同,有些樣式沒有生效。利用搜索引擎,找到了問題所在以及解決辦法:
main.js中的引入順序決定了打包后css的順序,組件內的樣式沒有生效可能是被第三方組件樣式覆蓋了,所以把第三方組件放在前面引入,router放在后面引入,就可以實現組件樣式在第三方樣式之后渲染。代碼如下:

main.js

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
//先引入第三方組件
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
//后引入router
import router from './router'
import store from './vuex/store'

Vue.use(ElementUI)

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})

———————————————— 

版權聲明:本文為CSDN博主「Arlisol」的原創文章。
原文鏈接:https://blog.csdn.net/Dg_Zing/article/details/87907796


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM