小程序API能力汇总——基础容器API(三)

ty.getAccountInfo

获取小程序账号信息

需引入MiniKit,且在>=3.1.0版本才可使用

参数

Object object

属性 类型 默认值 必填 说明
complete function 接口调用结束的回调函数(调用成功、失败都会执行)
success function 接口调用成功的回调函数
fail function 接口调用失败的回调函数

object.success 回调参数

参数

Object res

属性 类型 说明
miniProgram MiniProgramAccountInfo 小程序账号信息

MiniProgramAccountInfo

Property Type Description
appId string 小程序 ID
envVersion string 小程序版本: - develop:开发版 - trail:体验版 - release:正式版
version string 版本号

object.fail 回调参数

参数

Object res

属性 类型 说明
errorMsg string 插件错误信息
errorCode string 错误码
innerError object 插件外部依赖错误信息 {errorMsg: string, errorCode: string }

函数定义示例

复制代码
export type MiniProgramAccountInfo = {
  /** 小程序 ID */
  appId: string;
  /**
   * 小程序版本
   * develop: 开发版
   * trail: 体验版
   * release: 正式版
   */
  envVersion: string;
  /** 小程序版本号 */
  version: string;
};
/**
 * 获取小程序账号信息
 */
export function getAccountInfo(params?: {
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
  complete?: () => void;
  /** 接口调用成功的回调函数 */
  success?: (params: {
    /** 小程序账号信息 */
    miniProgram: MiniProgramAccountInfo;
  }) => void;
  /** 接口调用失败的回调函数 */
  fail?: (params: {
    errorMsg: string;
    errorCode: string | number;
    innerError: {
      errorCode: string | number;
      errorMsg: string;
    };
  }) => void;
}): void;

ty.getAccountInfoSync

获取小程序账号信息同步方法

需引入MiniKit,且在 >=3.1.0 版本才可使用

getAccountInfo 的同步版本

返回值

属性 类型 说明
miniProgram MiniProgramAccountInfo 小程序账号信息

MiniProgramAccountInfo

Property Type Description
appId string 小程序 ID
envVersion string 小程序版本: - develop:开发版 - trail:体验版 - release:正式版
version string 版本号

函数定义示例

复制代码
export type MiniProgramAccountInfo = {
  /** 小程序 ID */
  appId: string;
  /**
   * 小程序版本
   * develop: 开发版
   * trail: 体验版
   * release: 正式版
   */
  envVersion: string;
  /** 小程序版本号 */
  version: string;
};
/**
 * 获取小程序账号信息
 */
export function getAccountInfoSync(): {
  /** 小程序账号信息 */
  miniProgram: MiniProgramAccountInfo;
};

ty.setBoardIcon

设置小程序看板的 icon

需引入MiniKit,且在>=3.0.3版本才可使用

参数

Object object

属性 类型 默认值 必填 说明
icon string 看板的 icon
complete function 接口调用结束的回调函数(调用成功、失败都会执行)
success function 接口调用成功的回调函数
fail function 接口调用失败的回调函数

函数定义示例

复制代码
/**
 * 小程序看板的icon,小程序icon,面板icon等
 */
export function setBoardIcon(params: {
  /** 看板的icon */
  icon: string;
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
  complete?: () => void;
  /** 接口调用成功的回调函数 */
  success?: (params: null) => void;
  /** 接口调用失败的回调函数 */
  fail?: (params: {
    errorMsg: string;
    errorCode: string | number;
    innerError: {
      errorCode: string | number;
      errorMsg: string;
    };
  }) => void;
}): void;

ty.setBoardIconSync

设置小程序看板的 icon

需引入MiniKit,且在>=3.0.3版本才可使用

ty.setBoardIcon 的同步版本

参数

Object object

属性 类型 默认值 必填 说明
icon string 看板的 icon

函数定义示例

复制代码
/**
 * 设置小程序看板的 icon
 */
export function setBoardIconSync(params: {
  /** 看板的icon */
  icon: string;
}): null;

ty.showBoardTitleIcon

显示小程序看板中的标题和 icon

需引入MiniKit,且在>=3.0.3版本才可使用

参数

Object object

属性 类型 默认值 必填 说明
complete function 接口调用结束的回调函数(调用成功、失败都会执行)
success function 接口调用成功的回调函数
fail function 接口调用失败的回调函数

函数定义示例

复制代码
/**
 * 显示小程序看板中的标题和icon
 */
export function showBoardTitleIcon(params?: {
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
  complete?: () => void;
  /** 接口调用成功的回调函数 */
  success?: (params: null) => void;
  /** 接口调用失败的回调函数 */
  fail?: (params: {
    errorMsg: string;
    errorCode: string | number;
    innerError: {
      errorCode: string | number;
      errorMsg: string;
    };
  }) => void;
}): void;

ty.showBoardTitleIconSync

The synchronous method used to display the title and icon of the miniapp dashboard.

Be sure to import MiniKit 3.0.3 or later.

The synchronous method of ty.showBoardTitleIcon.

Examples of function definitions

复制代码
/**
 * Display the title and icon of the miniapp dashboard.
 */
export function showBoardTitleIconSync(): null;

ty.hideBoardTitleIcon

隐藏小程序看板中的标题和 icon

需引入MiniKit,且在>=3.0.3版本才可使用

参数

Object object

属性 类型 默认值 必填 说明
complete function 接口调用结束的回调函数(调用成功、失败都会执行)
success function 接口调用成功的回调函数
fail function 接口调用失败的回调函数

函数定义示例

复制代码
/**
 * 隐藏小程序看板中的标题和icon
 */
export function hideBoardTitleIcon(params?: {
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
  complete?: () => void;
  /** 接口调用成功的回调函数 */
  success?: (params: null) => void;
  /** 接口调用失败的回调函数 */
  fail?: (params: {
    errorMsg: string;
    errorCode: string | number;
    innerError: {
      errorCode: string | number;
      errorMsg: string;
    };
  }) => void;
}): void;

ty.hideBoardTitleIconSync

隐藏小程序看板中的标题和 icon 同步方法

需引入MiniKit,且在>=3.0.3版本才可使用

ty.hideBoardTitleIcon 的同步版本

函数定义示例

复制代码
/**
 * 隐藏小程序看板中的标题和icon
 */
export function hideBoardTitleIconSync(): null;

👉 立即开发

相关推荐
爱编程的王小美1 小时前
小程序开发指南
小程序
清岚_lxn3 小时前
原生SSE实现AI智能问答+Vue3前端打字机流效果
前端·javascript·人工智能·vue·ai问答
ZoeLandia4 小时前
Element UI 设置 el-table-column 宽度 width 为百分比无效
前端·ui·element-ui
m0_684598534 小时前
如何开发英语在线训练小程序:从0到1的详细步骤
java·微信小程序·小程序·小程序开发
ml130185288744 小时前
开发一个环保回收小程序需要哪些功能?环保回收小程序
java·大数据·微信小程序·小程序·开源软件
橘子味的冰淇淋~4 小时前
解决 vite.config.ts 引入scss 预处理报错
前端·vue·scss
萌萌哒草头将军5 小时前
💎这么做,cursor 生成的代码更懂你!💎
javascript·visual studio code·cursor
小小小小宇6 小时前
V8 引擎垃圾回收机制详解
前端
lauo6 小时前
智体知识库:ai-docs对分布式智体编程语言Poplang和javascript的语法的比较(知识库问答)
开发语言·前端·javascript·分布式·机器人·开源
拉不动的猪7 小时前
设计模式之------单例模式
前端·javascript·面试