Vue使用elementUi,常使用externals,通过cdn导入报错,无法找到对应的el标签,浏览器没办法渲染

这是报错

img

public文件夹下的index.html

<!DOCTYPE html>
<html lang="">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
    <title>
        <%= htmlWebpackPlugin.options.title %>
    </title>
    <!-- 引入Vue -->
    <script src="https://cdn.staticfile.org/vue/2.5.22/vue.min.js"></script>
    <!-- element-ui 的样式表文件 -->
    <link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.8.2/theme-chalk/index.css" />
    <!-- element-ui 的 js 文件 -->
    <script src="https://cdn.staticfile.org/element-ui/2.8.2/index.js"></script>
</head>

<body>
    <noscript>
      <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
    </noscript>
    <div id="app"></div>
    <!-- built files will be auto injected -->
</body>

</html>

src文件夹下的main.js

import Vue from 'vue'
import App from './App.vue'
Vue.config.productionTip = false

new Vue({
    render: (h) => h(App)
}).$mount('#app')

babel.config.js

module.exports = {
    presets: ['@vue/cli-plugin-babel/preset', ['@babel/preset-env', { modules: false }]],
    plugins: [
        [
            'component',
            {
                libraryName: 'element-ui',
                styleLibraryName: 'theme-chalk'
            }
        ]
    ]
}

vue.comfig.js

module.exports = {
    chainWebpack: (config) => {
        config.external('externals', {
            vue: 'Vue',
            'element-ui': 'ELEMENT'
        })
    }
}

我已经快被折磨疯,试了三个小时死活不行一直报错,各位朋友能告诉我应该怎么办嘛?

img

你cdn 都引入了 你还要这个 import 引入的包就没有意义了,两个 newVue就被覆盖了