html代码
<template>
<view>
<button @click="wxWebLogin">微信授权登录</button>
</view>
</template>
js端代码
//在methods中
wxWebLogin() {
// 1. 获取微信公众号的AppID
const appid = 'YOUR_APPID';
// 2. 设置回调URL(需在微信公众号平台配置)
const redirect_uri = encodeURIComponent('https://yourdomain.com/wx-callback');
// 3. 构造微信授权URL
const url =
`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${redirect_uri}&response_type=code&scope
=snsapi_userinfo&state=STATE#wechat_redirect`;
// 4. 跳转到微信授权页面
window.location.href = url;
}
上一篇:
threejs二、几何体和材质函数介绍
下一篇:
threejs一:的安装和基础使用