天天看点

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>