# Object wx.getOfficialComponentsInfo()

基础库 3.7.12 开始支持,低版本需做兼容处理

微信 Windows 版:支持

微信 Mac 版:支持

# 功能描述

获取所有官方组件的相关信息

# 返回值

# Object

全部组件的信息

属性 类型 说明
notificationComponentInfo Object 通知组件信息
结构属性 类型 说明
name string 组件的名称
isVisible boolean 组件是否显示
boundingClientRect Object 组件的布局位置信息
结构属性 类型 说明
width number 宽度,单位:px
height number 高度,单位:px
top number 上边界坐标,单位:px
right number 右边界坐标,单位:px
bottom number 下边界坐标,单位:px
left number 左边界坐标,单位:px

# 示例代码

const componentsInfo = wx.getOfficialComponentsInfo();
const { notificationComponentInfo } = componentsInfo;
if (notificationComponentInfo.isShow) {
  console.log(notificationComponentInfo.boundingClientRect.width);
  console.log(notificationComponentInfo.boundingClientRect.height);
  console.log(notificationComponentInfo.boundingClientRect.top);
  console.log(notificationComponentInfo.boundingClientRect.left);
  console.log(notificationComponentInfo.boundingClientRect.bottom);
  console.log(notificationComponentInfo.boundingClientRect.right);
}
点击咨询小助手