oixjd@qq.com
oixjd@qq.com
  • 发布:2019-06-12 19:51
  • 更新:2019-06-13 19:36
  • 阅读:150

uni-app中微信小程序按钮无法获取用户信息,出现“GetUserInfo is not a function”错误。

分类:uni-app

各位兄弟,最近在学习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

请问这里到底是啥问题,尝试了几天,都不行。

2019-06-12 19:51 分享
已邀请:
DCloud_UNI_FXY

DCloud_UNI_FXY

注意自己模板里写的方法名的大小写

oixjd@qq.com

oixjd@qq.com (作者) - 70后IT男

谢谢解答,问题解决了!!

要回复问题请先登录注册