DWQA QuestionsCategory: ProgramHow to introduce element-ui into other JS by introducing element-ui into CDN in Vue
Comedy End asked 2 weeks ago

stayindex.htmlIntroducing element with CDN

<link rel="stylesheet" href="https://unpkg.com/[email protected]/lib/theme-chalk/index.css">

webpack.base.conf.jsThe code is as follows

externals: {
    'vue': 'Vue',
    'vue-router': 'VueRouter',
    'axios': 'axios',
    'element-ui': 'element-ui',
    'i18n': 'i18n',

Now I want to write in their own JS using element components how to reference

import {Message} from 'element-ui'

In this way, Message will be used to reportexternal "element-ui"?c60b:1 Uncaught ReferenceError: element is not definederror
Thank you

9 Answers
Best Answer
SevenOutman answered 2 weeks ago

CDN versionelement-uiThe global variable set isELEMENT

externals: {
  'element-ui': 'ELEMENT',
I love Samoye answered 2 weeks ago

Element is not defined after configuration modification, because Element relies on Vue, vue. JS needs to be introduced before element-ui, so vue. JS also needs to be changed to cnd.

A Program answered 2 weeks ago

Excuse me, has the boss solved it?

Xuyuey answered 2 weeks ago

Hello, why do you still make a mistake after correcting this?

ELEMENT is not defined
xuzhouqwerdf replied 2 weeks ago

Same question

xuzhouqwerdf answered 2 weeks ago

What should main.js look like after introducing Vue and element-ui with cdn?