問題1:wepy文檔中說:在Page頁面實(shí)例中,可以通過this.$parent來訪問App實(shí)例。那如果我想在一個(gè)js中訪問app實(shí)例該怎么做呢?wepy.login({
success: function({ code }) {
ajax('user/login', {
code
}).then(res => { if (res) {
wx.setStorageSync('user_id', res.user_id)
wx.setStorageSync('auth_token', res.auth_token)
}
// 想在此處把res.store_id 和 res.store_name存在app.globalData中
getDefaultStore().then(res => {
fn()
})
})
}
})問題2:wepy文檔中說:// WePY 使用方式, 需要開啟 Promise 支持,參考開發(fā)規(guī)范章節(jié)wepy.request('xxxx').then((d) => console.log(d));1、怎么開啟Promise支持呢?2、是不是所有的原生微信api都能用wepy.apiName的方式去調(diào)用。比如:wx.login可以用wepy.login、wx.setNavigationBarTitle可以用wepy.setNavigationBarTitle
wepy 在一個(gè)js文件中怎么取到app實(shí)例
鴻蒙傳說
2018-07-21 08:48:55