微信小程序添加公众号关注组件
小程序 大约 899 字开启公众号关注组件
在设置
选项卡中的关注公众号
tab页下,开通公众号关注组件
(设置的公众号需与小程序主体一致)。
组件展示场景
- 扫小程序码打开时
- 微信聊天列表下拉后的
最近使用
打开时 - 从其他小程序返回
前置条件
- 在上述展示场景外该组件不会展示
- 基础库需在
2.3.0
及以上 - 组件限定最小宽度为
300px
,高度为定值84px
- 每个页面只能配置一个该组件
特别注意
组件不要嵌套在wx:if
, wx:else
中,否则可能会重复渲染,导致提示创建多次错误而不展示组件。
调试设置
普通编译
下拉框选择:添加编译模式添加编译模式
中,进入场景选择:1011
扫描二维码- 开发工具右上角
详情
菜单中的本地设置
选项卡中调试基础库选择:2.3.0
及以上版本
代码实现
wxml
<official-account style="width:100%;height:168rpx;" bindload="bindLoad" binderror="bindError"></official-account>
js
bindLoad: function(e) {
var status = e.detail.status;
var errMsg = e.detail.errMsg;
console.log("official-account bind load#status=" + status + ", errMsg=" + errMsg)
},
bindError: function(e) {
var status = e.detail.status;
var errMsg = e.detail.errMsg;
console.log("official-account bind error#status=" + status + ", errMsg=" + errMsg)
}
参考
https://developers.weixin.qq.com/miniprogram/dev/component/official-account.html
阅读 3942 · 发布于 2020-02-03
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb扫描下方二维码关注公众号和小程序↓↓↓

昵称:
随便看看
换一批
-
Spring Boot Undertow 上传文件后没有可读权限阅读 5653
-
移动端 input 输入框使软键盘回车键变为搜索按钮阅读 4671
-
MySQL 索引条件下推阅读 1530
-
MongoDB 字段重命名阅读 2600
-
PostgreSQL 时间戳转毫秒值并去除小数位阅读 5791
-
Rust Cargo update crate.io index 时无响应阅读 681
-
MyBatis Cause: java.lang.IndexOutOfBoundsException: Index: 5, Size: 5阅读 6591
-
OpenResty 整合 LuaRocks - Windows10阅读 3532
-
Redis 使用 HyperLogLog 统计独立 IP 数阅读 2750
-
MongoDB 搭建分片集群阅读 3379