問題1:wepy文檔中說:在Page頁面實例中,可以通過this.$parent來訪問App實例。那如果我想在一個js中訪問app實例該怎么做呢?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 支持,參考開發規范章節wepy.request('xxxx').then((d) => console.log(d));1、怎么開啟Promise支持呢?2、是不是所有的原生微信api都能用wepy.apiName的方式去調用。比如:wx.login可以用wepy.login、wx.setNavigationBarTitle可以用wepy.setNavigationBarTitle
wepy 在一個js文件中怎么取到app實例
鴻蒙傳說
2018-07-21 08:48:55