weex icon indicating copy to clipboard operation
weex copied to clipboard

为什么Weex-loader-0.3.1还是不支持在 js 中 require('@weex-module/stream');

Open resse92 opened this issue 10 years ago • 3 comments

image

resse92 avatar Sep 13 '16 05:09 resse92

@Jinjiang

jinyue-rdj avatar Sep 14 '16 02:09 jinyue-rdj

@RLZHU
这边有个临时的方案: 如果require 语句是否在一个 .js 文件中,而不是在 .we 文件中。则暂时可以通过以下特殊写法实现:

// use this piece of code below to get Weex native module "modal"   
var modal
__weex_define__('@weex-temp/x', function (__weex_require__) {
  modal = __weex_require__('@weex-module/modal')
})

// use APIs in "modal" module
modal.toast({message: 'hello'})

@jinyue-rdj

vczero avatar Sep 14 '16 02:09 vczero

还可以参考这里 https://github.com/weexteam/article/issues/20

Jinjiang avatar Sep 14 '16 02:09 Jinjiang