vue-cli
introduce element using cdn in index.html
<link rel="stylesheet" href="https://unpkg.com/element-ui@2.3.7/lib/theme-chalk/index.css">
<script src="https://cdn.bootcss.com/vue/2.5.2/vue.min.js"></script>
<script src="https://cdn.bootcss.com/vue-router/3.0.1/vue-router.min.js"></script>
<script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>
<script src="https://cdn.bootcss.com/vue-i18n/7.6.0/vue-i18n.min.js"></script>
<script src="https://unpkg.com/element-ui@2.3.7/lib/index.js"></script>
The code in webpack.base.conf.js
is as follows
externals: {
"vue": "Vue",
"vue-router": "VueRouter",
"axios": "axios",
"element-ui": "element-ui",
"i18n": "i18n",
},
now you want to use the element component in your own js. How to reference it
import {Message} from "element-ui"
Message(123);
if you use Message in this way, you will report external "element-ui"? c60b:1 Uncaught ReferenceError: element is not defined
error
Thank you