陈贝贝 發表於 2021-4-17 18:12:00

uni app 微信小程序登录问题 getUserProfile

<blockquote>
<p>uni app 开发微信小程序发布后被拒绝了,是因为我用的是以前的微信登录方式<br>
4.13号后一定要来新的登录方式(<code>getUserProfile</code>)实现登录功能,否则腾讯被拒绝。<br>
<img src="https://img2020.cnblogs.com/blog/2205076/202104/2205076-20210417181036667-140826906.png" alt="" loading="lazy"></p>
</blockquote>
<h4 id="不需要以前那样什么open-type等等直接用click方法调用">不需要以前那样什么open-type等等;直接用<code>@click</code>方法调用</h4>
<p><code>&lt;button@click="newWxLogin"&gt;新登录&lt;/button&gt;</code></p>
<pre><code>newWxLogin(){
    uni.getUserProfile({
      desc:'登录',
      success:(res)=&gt;{
             console.log(res);
        },
        fail:(err)=&gt;{
             console.log(err);
      }
    })
}
</code></pre>
<blockquote>
<p>可是我的报错了<code>uni.getUserProfile is not a function</code>是因为微信开发者工具设置错误<br>
解决方式:把微信开发者工具的本地设置版本设置为2.16.0即可<br>
<img src="https://img2020.cnblogs.com/blog/2205076/202104/2205076-20210417180532699-79878772.png" alt="" loading="lazy"></p>
</blockquote>
<h4 id="列子">列子:</h4>
<pre><code>&lt;template&gt;
        &lt;view style="padding-top: 100upx;"&gt;
                &lt;button@click="newWxLogin"&gt;新登录&lt;/button&gt;
        &lt;/view&gt;
&lt;/template&gt;

&lt;script&gt;
        export default {
                data() {
                        return {
                               
                        }
                },
                methods: {
                        newWxLogin(){
                                uni.getUserProfile({
                                        desc:'登录',
                                        success:(res)=&gt;{
                                                console.log(res);
                                        },
                                        fail:(err)=&gt;{
                                                console.log(err);
                                        }
                                })
                        }
                }
        }
&lt;/script&gt;

&lt;style&gt;


&lt;/style&gt;

</code></pre><br><br>
来源:https://www.cnblogs.com/nurmemet/p/14671695.html
頁: [1]
查看完整版本: uni app 微信小程序登录问题 getUserProfile