创建于2024-09-29更新于 2025-03-22
02. SDK 使用
封装了一些微信常用的 js-sdk 操作。
0.2.1 配置页面是否需要开启授权
| 参数 | 类型 | 默认值 |
|---|---|---|
| requiresAuth | boolean | false |
{
path: '/home',
name: 'home',
component: () => import('/@/views/home/index.vue'),
meta: {
title: '首页',
keepAlive: false,
requiresAuth: true, // 是否需要授权
},
},0.2.3 自动分享配置参数
shareInfo
| 参数 | 类型 | 说明 |
|---|---|---|
| isShare | boolean | 是否开启自动分享配置参数 |
| shareTitle | string | 分享的标题 |
| imgUrl | string | 分享的卡片图片 |
| desc | string | 分享的描述 |
{
path: '/shareAuto',
name: 'shareAuto',
component: () => import('/src/views/shareAuto/ShareAuto.vue'),
meta: {
title: '',
shareInfo: {
isShare: true,
shareTitle: '',
imgUrl: '',
desc: '',
},
},
},0.2.4 手动分享配置参数
import { useWxSDK } from '/@/hooks/useWxSDK';
import { useWxShare } from '/@/hooks/useWxShare';
const { initConfig } = useWxSDK();
initConfig().then(() => {
useWxShare({
title: '',
desc: '',
imgUrl: '',
});
});- 啥是自动配置,是不是说,整个页面固定分享参数,而手动分享是说根据业务需要自行指定。