Taro.createSelectorQuery() 在微信中无法使用



  • Taro.createSelectorQuery().select('#inbox').boundingClientRect(function (rect) {
      console.log('in rect:', rect)
      let width = rect.width
      this.setState({
        inWidth: width
      })
    }).exec()
    
    <View id="outbox"></View>
    

    在H5端正常,在小程序端报错

    thirdScriptError
    Cannot read property 'width' of null;at SelectorQuery callback function
    TypeError: Cannot read property 'width' of null
    

登录后回复