mpvue開發微信小程序,分享按鈕報錯:`Cannot read property 'apply' of null`

用mpvue開發微信小程序,分享按鈕報錯:Cannot read property 'apply' of null

thirdScriptError
Cannot read property 'apply' of null;at pages/commit-done/index page onShareAppMessage function
TypeError: Cannot read property 'apply' of null
    at t.l (http://127.0.0.1:40968/appservice/__dev__/WAService.js:18:7100)
    at cn (http://127.0.0.1:40968/appservice/__dev__/WAService.js:19:9477)
    at Function.un (http://127.0.0.1:40968/appservice/__dev__/WAService.js:19:10438)
    at http://127.0.0.1:40968/appservice/__dev__/WAService.js:18:9835
    at http://127.0.0.1:40968/appservice/__dev__/WAService.js:19:11296
    at n (http://127.0.0.1:40968/appservice/__dev__/WAService.js:5:30424)
    at a (http://127.0.0.1:40968/appservice/appservice?t=1534209702568:3511:9566)
    at e.registerCallback (http://127.0.0.1:40968/appservice/appservice?t=1534209702568:3511:9753)
    at n.forEach (http://127.0.0.1:40968/appservice/appservice?t=1534209702568:3511:5638)
    at Array.forEach (<anonymous>)
console.error @ VM5516:1
errorReport @ WAService.js:4
thirdErrorReport @ WAService.js:4
(anonymous) @ WAService.js:3
l @ WAService.js:18
cn @ WAService.js:19
un @ WAService.js:19
(anonymous) @ WAService.js:18
(anonymous) @ WAService.js:19
n @ WAService.js:5
a @ appservice?t=1534209702568:3511
e.registerCallback @ appservice?t=1534209702568:3511
n.forEach @ appservice?t=1534209702568:3511
d @ appservice?t=1534209702568:3511
k.onmessage @ appservice?t=1534209702568:3511

這個應該是 把 onShareAppMessage這個方法 寫到 methods 裏面去了吧,我開始也遇到了,要寫methods外,他是和 生命週期一級的

ex:

<template>
</template>
<script>
export default {
	data() {
		return {}
	},
	methods: {
	},
	onShareAppMessage: function(options) {
		console.log('分享的代碼!!')
	}
}
</script>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章