开放者工具版本:1.05.2110110
按向导创建项目,语言选择typescript,发现真机调试时,在页面里调用getApp()返回undefined
语言选择js,则正常
Page({
data: {
motto: 'Hello World',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo'),
canIUseGetUserProfile: false,
canIUseOpenData: wx.canIUse('open-data.type.userAvatarUrl') && wx.canIUse('open-data.type.userNickName') // 如需尝试获取用户信息可改为false
},
// 事件处理函数
bindViewTap() {
wx.navigateTo({
url: '../logs/logs',
})
},
onLoad() {
console.log('---------index.onLoad---------')
console.log(getApp<IAppOption>())
// @ts-ignore
if (wx.getUserProfile) {
this.setData({
canIUseGetUserProfile: true
})
}
},
试下最新版的 nightly https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html
开发版 Nightly Build (1.05.2110202)