@bluesyoung/wechat-auth
v0.0.2
Published
微信公众号网页授权
Downloads
4
Maintainers
Readme
微信公众号网页授权
安装
使用包管理器安装
# 选择一个你喜欢的包管理器
# NPM
$ npm install @bluesyoung/wechat-auth --save
# Yarn
$ yarn add @bluesyoung/wechat-auth
# pnpm
$ pnpm add @bluesyoung/wechat-auth
cdn 引入
<!-- unpkg -->
<script src="//unpkg.com/@bluesyoung/wechat-auth"></script>
<!-- jsdelivr -->
<script src="//cdn.jsdelivr.net/npm/@bluesyoung/wechat-auth"></script>
<script>
const code = new window.YoungWechatAuth().getCode();
</script>
使用示例
import YoungWechatAuth from '@bluesyoung/wechat-auth';
// 网页获取授权码
const code = new YoungWechatAuth({
appid: 'wx520c15f417810387',
// state: 'young_wechat_auth',
// redirect: location.href
}).getCode();
// 网页授权登录,微信外扫码,微信内网页授权登陆(snsapi_userinfo)
const code = new YoungWechatAuth({
appid: 'wx520c15f417810387',
// 微信开放平台-应用 appid,扫码登录必传
open_appid: 'wxbdc5610cc59c1631',
// state: 'young_wechat_auth',
// redirect: location.href
}).getCode('login');
if (code) {
// do sth
}