mamahaha
V2EX  ›  Vue.js

动态引用组件遇到 Vue.use(xxx)怎吗办??

  •  
  •   mamahaha · Aug 10, 2019 · 3345 views
    This topic created in 2669 days ago, the information mentioned may be changed or developed.

    平常的时候是这样的
    import Xxx from 'ant-design-vue/lib/xxx';
    Vue.use(Xxx);

    动态引入是这样的
    const Xxx=()=>import('ant-design-vue/lib/xxx');

    那吗 Vue.use(Xxx)怎吗办啊?

    3 replies  •  2019-08-10 23:17:13 +08:00
    yikuo
    yikuo
    Aug 10, 2019 via Android❤️1
    1
    then ?
    hewelzei
    hewelzei
    Aug 10, 2019 via Android❤️1
    2
    import(xxx)返回的是 Promise, 直接这样写 Xxx().then(res => Vue.use(res))
    hackfly
    hackfly
    Aug 10, 2019❤️1
    3
    组件的 use 都要提供一个 install 函数,看看里面就可以修改为 import 形式的了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2088 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 14:42 · PVG 22:42 · LAX 06:42 · JFK 09:42
    ♥ Do have faith in what you're doing.