鍍金池/ 問答/HTML/ 微信小程序設(shè)置getSystemInfo怎么在wxml輸出無效?

微信小程序設(shè)置getSystemInfo怎么在wxml輸出無效?

js:
getSystemInfo() {

wx.getSystemInfo({
  success: function (res) {
    deviceWidth:res.windowWidth
    deviceHeight:res.windowHeight
  }
})

},
onLoad() {

this.getSystemInfo()

},

wxml:

<scroll-view scroll-y="true" style="height:{{ deviceHeight }}"  scroll-into-view="{{toView}}"  bindscrolltoupper="upper" bindscrolltolower="lower" bindscroll="scroll" >

wx.getSystemInfo已經(jīng)獲得了寬高 在輸出卻是0

回答
編輯回答
故林

onLoad() {

var self = this
wx.getSystemInfo({
  success: function (res) {
    self.setData({
      deviceWidth: res.windowWidth,
      deviceHeight: res.windowHeight,
    })
  }
})

},

2018年1月22日 02:29