Skip to content
广告位招租广告位招租
  • 由于插件存在引入写法/使用问题,故统一说明
  • 插件的使用和引入在特定的SDK下会存在差异,所以按照插件文档为准!

  • 引入 1 ( 例如 Turbo UI Plugins - 微信授权登录)
    • 更清晰的使用
    • 更好的回调
    • SDK内部本身处理方便
ts
import {
    tWxRegister,
    TWeixinRegisterOptions,
    TWeixinResult,
    tWxAuth,
    TWeixinAuthOptions
} from "@/uni_modules/t-weixin-api"

  • 引入 2 ( 例如 Turbo UI Plugins - 微信授权登录)
    • 别名使用,防止冲突
    • 类型方法使用须以tWeixin.tWxAuth
    • UTS内部本身处理方便
ts
import * as tWeixin from "@/uni_modules/t-weixin-api"

  • 使用 1 ( 例如 Turbo UI Plugins - 微信授权登录)
    • SDK 内部回调不好获取
    • Promise 接管才能拿到
ts
new Promise((resolveT: (value: TWeixinResult) => void,rejectT: (value: TWeixinResult) => void) => {
    tWxAuth({
        scope: "snsapi_userinfo",
        state: "test",
        resolve: (result:TWeixinResult) => {
            resolveT(result)
        },
        reject: (result: TWeixinResult) => {
            rejectT(result)
        }
    } as TWeixinAuthOptions)
}).then((result: TWeixinResult) => {
    console.log(result)
})