weexteam / article

This repos is a third party collection, and is not developed nor maintained by Apache Weex.
1.22k stars 141 forks source link

weex-vue-render 12.14 #167

Open Kntt opened 6 years ago

Kntt commented 6 years ago

image

使用requireModule, 返回的是undefined, 无论dom还是其他模块都是这样

export function initIconFont () {
  var bundleUrl = weex.config.bundleUrl
  var url = bundleUrl.split('/').slice(0, -1).join('/');
  if (url.indexOf('#') !== -1) {
    url = url.slice(0, url.indexOf('#') - 1)
  }
  console.log(url)
  var dom = weex.requireModule('dom').addRule('fontFace', {
    'fontFamily': "iconfont",
    'src': `url('${url}static/fonts/iconfont.ttf')`
  });
  console.log(dom)  // undefined
}

但是直接用:

weex.requireModule('dom').addRule('fontFace', {
    'fontFamily': "iconfont",
    'src': `url('${url}static/fonts/iconfont.ttf')`
  })
Yuamo commented 6 years ago
const storage = weex.requireModule('storage')
// the storage is undefined!

me too!help!!!

Yuamo commented 6 years ago
 "weex-vue-render": "^0.11.57"
CodeDreamfy commented 6 years ago

貌似不能赋值,只能直接使用weex.requireModule('dom'). getComponentRect

或者

this.dom.getComponentRect()这样用。

computed: {
    dom() {
      return weex.requireModule('dom')
    },
}