打开小程序首页,点击去登陆,登陆成功后返回到首页,首页有分享按钮,此时分享按钮点击报错Cannot convert undefined or null to object,右上角选择重新打开小程序可以分享
//报错信息:
VM8 asdebug.js:formatted:4499 TypeError: Cannot convert undefined or null to object
at o.keys (<anonymous>)
at VM2136 WAService.js:2
at VM2136 WAService.js:2
at i (VM8 asdebug.js:formatted:4497)
at c (VM8 asdebug.js:formatted:4504)
at VM8 asdebug.js:formatted:181
at Set.forEach (<anonymous>)
at f (VM8 asdebug.js:formatted:179)
at e.exports.g (VM8 asdebug.js:formatted:188)
at VM8 asdebug.js:formatted:131(env: Windows,mp,1.05.2110290; lib: 2.17.0)
//业务代码:
<template>
<!-- 分享 -->
<view>
<button open-type="share" class="share_btn df_end_start" :data-blogInfo="blog">
<image src="/static/images/share_icon.png" mode="" class="share_icon" v-if="fontColor == '#fff'"></image>
<image src="/static/images/share_icon_333.png" mode="" class="share_icon" v-if="fontColor == '#333'">
</image>
</button>
</view>
</template>
<script>
export default {
props: {
fontColor: {
type: String,
default: "#fff"
},
blog: {
type: Object,
default: {}
}
},
data() {
return {
}
},
mounted() {},
methods: {}
}
</script>
<style scoped>
.share_btn {
background: none;
}
.share_icon {
width: 37rpx;
height: 37rpx;
margin-left: 49rpx;
}
</style>
不建议直接调用生命周期函数onLoad
uni.switchTab({ url: "/pages/mokaIndex/mokaIndex", success() { let page = getCurrentPages().pop(); //跳转页面成功之后 if (!page) return; // page.onLoad(); //调用此方法就会导致报错 page.$vm.loadData && page.$vm.loadData(); //直接调用自定义方法就不会有报错 } }); 以上代码是修改后可以的,但不知道是为什么,有大佬知道的话希望能帮忙解决一下,非常感谢!!!