V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
mamahaha
V2EX  ›  Vue.js

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

  •  
  •   mamahaha · 2019-08-10 19:33:02 +08:00 · 2450 次点击
    这是一个创建于 1693 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

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

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

    3 条回复    2019-08-10 23:17:13 +08:00
    yikuo
        1
    yikuo  
       2019-08-10 22:28:30 +08:00 via Android   ❤️ 1
    then ?
    hewelzei
        2
    hewelzei  
       2019-08-10 23:07:11 +08:00 via Android   ❤️ 1
    import(xxx)返回的是 Promise, 直接这样写 Xxx().then(res => Vue.use(res))
    hackfly
        3
    hackfly  
       2019-08-10 23:17:13 +08:00   ❤️ 1
    组件的 use 都要提供一个 install 函数,看看里面就可以修改为 import 形式的了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2800 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 11:47 · PVG 19:47 · LAX 04:47 · JFK 07:47
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.