mamahaha
V2EX  ›  Vue.js

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

  •  
  •   mamahaha · Aug 10, 2019 · 3092 views
    This topic created in 2533 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
        1
    yikuo  
       Aug 10, 2019 via Android   ❤️ 1
    then ?
    hewelzei
        2
    hewelzei  
       Aug 10, 2019 via Android   ❤️ 1
    import(xxx)返回的是 Promise, 直接这样写 Xxx().then(res => Vue.use(res))
    hackfly
        3
    hackfly  
       Aug 10, 2019   ❤️ 1
    组件的 use 都要提供一个 install 函数,看看里面就可以修改为 import 形式的了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2505 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 16:01 · PVG 00:01 · LAX 09:01 · JFK 12:01
    ♥ Do have faith in what you're doing.