Skip to content

南熙航 SDK

封装

window.nxhSDK

ts
declare const nxhSDK: {
  init: typeof init; // 初始化
  useSDKStore: typeof useSDKStore;
  storeKey: symbol;
};

window.nxhSDKLib

ts
declare const nxhSDKLib: {
  storage: {}; //storage
  common: {}; //基于uniapp封装的方法
  cookie: {}; //cookie
  user: {}; //用户接口
  $init: {}; //页面初始化方法
  $post: {}; //请求方法
  share: {}; //分享数据
};

使用

ts
// 初始化 main.js
import { nxhSDK } from "@/nxhsdk.module.min";
nxhSDK.init({ uniApp: App, ssrApp: app });

// 使用封装好的公共数据
import { nxhSDK, nxhSDKLib } from "@/nxhsdk.module.min";
const store = nxhSDK.useSDKStore();

// 使用封装好的公共方法
import { nxhSDK, nxhSDKLib } from "@/nxhsdk.module.min";
const oCommon = nxhSDKLib.common;
oCommon.isWechat();

// 页面初始化
import { nxhSDKLib } from "@/nxhsdk.module.min";
nxhSDKLib.$init(() => {
  console.log("页面初始化");
});

// 同理可使用user、cookie、storage、$post、share等方法