这是一个调用Ionic
的函数regularShare(){
// only canonicalIdentifier is required
var properties = {
canonicalIdentifier: 'content/' + this.itemId
}
// create a branchUniversalObj variable to reference with other Branch methods
var branchUniversalObj = null
Branch.createBranchUniversalObject(properties).then(function (res) {
branchUniversalObj = res
// optional fields
var analytics = {
}
// optional fields
var properties = {
}
var message = 'Check out this link'
// optional listeners (must be called before showShareSheet)
branchUniversalObj.onShareSheetLaunched(function (res) {
// android only
console.log(res)
})
branchUniversalObj.onShareSheetDismissed(function (res) {
console.log(res)
})
branchUniversalObj.onLinkShareResponse(function (res) {
console.log(res)
})
branchUniversalObj.onChannelSelected(function (res) {
// android only
console.log(res)
})
// share sheet
branchUniversalObj.showShareSheet(analytics, properties, message)
});
}
当我将var消息更改为以下内容时,它会出错。错误如下。
var message = "Check out " + this.itemDetails.name + " (" + this.itemDetails.subcat+ ") in " + this.itemDetails.location + "."+ " Address: " + this.itemDetails.address+ ". Contact: " + this.itemDetails.phone
错误:错误错误:未捕获(在承诺中):TypeError:undefined不是对象(评估'this.itemDetails')
但是,在我的所有其他函数中,使用相同的消息和变量似乎运行良好。
只是尝试将变量的值放在消息中而不是默认消息中:查看此链接
谢谢:)
答案 0 :(得分:0)
为了让它正常工作,我不得不从
改变这一行Branch.createBranchUniversalObject(properties).then(function (res) {
要
Branch.createBranchUniversalObject(properties).then((res) => {