Open mistkafka opened 7 years ago
@mistkafka Reuirejs?
webpack 里用import socialShare from 'social-share.js/dist/js/social-share.min.js';再.share($config)有问题,而用import socialShare from 'social-share.js/dist/js/jquery.share.min';便可以正常config了
纠结了半天,发现只要把initialized重设为true就行了:document.querySelectorAll('.social-share, .share-component').forEach(v => v.initialized = false);
。用的require.ensure引入
目前share.js的生命周期是这样的: share.js加载 --> 加载完毕后运行相应的配置的js --> (window继续loading) --> loading完毕执行share.js内部注册的socialShare()
如果我想在AMD中使用,完全使用不了。我也没办法控制socialShare()的执行,因为当我使用socialShare()的时候,页面早就load了 内部注册的socialShare()已经抢先执行并且锁住了initialized。