[Big Pit] The WeChat applet getUserInfo interface is obsolete and the authorization window cannot pop up.

1. Problem

2. Plan

  • Background: WeChat newly added getUserProfile interface
  • Disadvantages: Only supports WeChat applet basic library 2.10.4-2.27.0
  • measure:
    • Modified version: WeChat Developer Tools => Details in the upper right corner => Local Settings => Debugging Basic Library => Select version 2.10.4-2.27.0
    • Modify the code:
    <button @click="getUserProfile">一键登录</button>
    
    methods: {
          
          
    	getUserProfile(e){
          
          
             uni.getUserProfile({
          
          
    	           desc:'请求授权',	// 必填项,声明获取用户个人信息后的用途,后续会展示在弹窗中
    	           success: (res) => {
          
          
    	             console.log(res.userInfo) 				// 用户信息
    	           },
    	           fail: (res) => {
          
          
    	             return uni.$showMsg('已取消登录授权')	// 用户拒绝授权提示
    	           }
             })
      	}
    }
    

Guess you like

Origin blog.csdn.net/weixin_64210950/article/details/130315290