按需導入的坑


1.webpack

  npm install unplugin-vue-components

  vue.config.js文件加段代碼

-------------------------------------------------------------------------------------------------

const Components = require('unplugin-vue-components/webpack')

const { ElementPlusResolver } = require('unplugin-vue-components/resolvers')
module.exports = {
  //   ...
  configureWebpack: {
    plugins: [
      Components({
        resolvers: [ElementPlusResolver()],
      }),
    ],
    module: {
      rules: [
        {
          test: /\.mjs$/,
          include: /node_modules/,
          type: 'javascript/auto',
        },
      ],
    },
  },
}
-----------------------------------------------------------------------------------------------------
 
module配置解決:Can’t import the named export ‘xxx’ from non EcmaScript module (only default export is available) 出現的報錯
 
------------------------------------------------------------------------------------------------------
 

  使用時發現一些消息框組件樣式竟然沒有了,只能這樣解決了

  main.js接口文件
  import 'element-plus/theme-chalk/el-message.css';
  import 'element-plus/theme-chalk/el-notification.css';
 


免責聲明!

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



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