問(wèn)題描述開(kāi)發(fā)項(xiàng)目中使用了vue+element-ui,在按需加載elementui模塊時(shí)這樣寫(xiě)就會(huì)報(bào)錯(cuò),我加載了以下三個(gè)模塊。import {Message, Select, Cascader} from 'element-ui';控制臺(tái)報(bào)錯(cuò):[Vue warn]: Unknown custom element: <el-option> - did you register the component correctly? For recursive components, make sure to provide the "name" option.上面提示的錯(cuò)誤是與Select模塊有關(guān),所以最開(kāi)始我以為是Select模塊的問(wèn)題,所以我就把Select模塊禁用了。import { Message, Cascader } from 'element-ui';雖然沒(méi)有報(bào)錯(cuò),但是Message的警告樣式會(huì)在我頁(yè)面一刷新時(shí)就出現(xiàn),正常情況下應(yīng)該在觸發(fā)事件時(shí)才出現(xiàn)。然后我又禁用了Message模塊,報(bào)了同樣的錯(cuò)誤。控制臺(tái)報(bào)錯(cuò):[Vue warn]: Unknown custom element: <el-option> - did you register the component correctly? For recursive components, make sure to provide the "name" option.之后我又多次嘗試各種寫(xiě)法,最后我將Message模塊挑出來(lái)單獨(dú)引入,沒(méi)有報(bào)錯(cuò)并且顯示正常。import Message from 'element-ui';import { Select, Cascader } from 'element-ui';但是會(huì)出現(xiàn)‘element-ui’多次入口的警告。這里要提一下,我在多個(gè)頁(yè)面都按需加載了elementUI的其他模塊,并沒(méi)有出現(xiàn)錯(cuò)誤或警告。這里想請(qǐng)教大家有沒(méi)有遇到類似問(wèn)題,該如何解決?
vue中按需加載element-ui模塊報(bào)錯(cuò)
達(dá)令說(shuō)
2018-09-08 16:06:40