各位兄弟,最近在学习Hcoder网站的“悦读”实例,里面有一个用uni-app写微信小程序登录,点击按钮显示登录信息。在uni-app的vue代码中这样写:
<!-- #ifdef MP-WEIXIN -->
<button type="primary" open-type="getUserInfo" @getuserinfo="GetUserInfo">使用微信登录</button>
<!-- #endif -->
export default {
data() {
return {
}
},
methods:{
getUserInfo: function(res){
console.log(res);
}
},
这里编译是没有错误信息的,但是到了微信小程序开发工具里,当点击按钮时,显示:
thirdScriptError
_vm.GetUserInfo is not a function; [Component] Event Handler Error @ pages/login/login#handleEvent
Error: _vm.GetUserInfo is not a function
at http://127.0.0.1:11698/appservice/common/vendor.js:857:23
at Array.forEach (<anonymous>)
at http://127.0.0.1:11698/appservice/common/vendor.js:847:23
at Array.forEach (<anonymous>)
at H.handleEvent [as e] (http://127.0.0.1:11698/appservice/common/vendor.js:837:17)
at Object.r.safeCallback (http://127.0.0.1:11698/appservice/dev/WAService.js:1:818220)
at http://127.0.0.1:11698/appservice/dev/WAService.js:1:959033
at f (http://127.0.0.1:11698/appservice/dev/WAService.js:1:964380)
at http://127.0.0.1:11698/appservice/dev/WAService.js:1:963487
at http://127.0.0.1:11698/appservice/dev__/WAService.js:1:229997
请问这里到底是啥问题,尝试了几天,都不行。
1***@qq.com
我也遇到了这个错误,不知道怎么回事啊,楼主能解答一下吗 0.0
2019-07-08 17:44
ponyzhang
回复 1***@qq.com:函数名字问题,正确格式:@getuserinfo="onGotUserInfo" ,事件里面的函数名一定用驼峰法命名
2019-08-13 14:16
9***@qq.com
回复 ponyzhang: 驼峰命名也不行怎么说
2020-04-19 08:55