- 在云开发数据库操作中‘{openid}’ 未被后台自动替换为小程序用户的 openid
https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/database/security-rules.html 按照文档的说法,在db请求中使用{openid}字符串在实际请求中应该会被自动替换为当前用户openid,但在实际应用时被当作普通字符串处理了 文档片段: [图片] [图片] 实际效果: 在云函数中的数据库add操作: [图片] 数据库中的效果 [图片]
2023-08-07 - 小程序如何自定义tabbar
如何自定义底部tabbar 组件呢? [图片] [图片] [图片] [图片] index.js 的内容: Component({ data: { selected: 0, color: "#7A7E83", selectedColor: "#3cc51f", list: [{ pagePath: "/index/index", iconPath: "/image/icon_component.png", selectedIconPath: "/image/icon_component_HL.png", text: "组件" }, { pagePath: "/index/index2", iconPath: "/image/icon_API.png", selectedIconPath: "/image/icon_API_HL.png", text: "接口" }] }, attached() { }, methods: { switchTab(e) { const data = e.currentTarget.dataset const url = data.path wx.switchTab({url}) this.setData({ selected: data.index }) } } }) index.json的内容: { "component": true } index.wxml的内容: <!--miniprogram/custom-tab-bar/index.wxml--> <cover-view class="tab-bar"> <cover-view class="tab-bar-border"></cover-view> <cover-view wx:for="{{list}}" wx:key="index" class="tab-bar-item" data-path="{{item.pagePath}}" data-index="{{index}}" bindtap="switchTab"> <cover-image src="{{selected === index ? item.selectedIconPath : item.iconPath}}"></cover-image> <cover-view style="color: {{selected === index ? selectedColor : color}}">{{item.text}}</cover-view> </cover-view> </cover-view> index.wxss的内容 .tab-bar { position: fixed; bottom: 0; left: 0; right: 0; height: 48px; background: white; display: flex; padding-bottom: env(safe-area-inset-bottom); } .tab-bar-border { background-color: rgba(0, 0, 0, 0.33); position: absolute; left: 0; top: 0; width: 100%; height: 1px; transform: scaleY(0.5); } .tab-bar-item { flex: 1; text-align: center; display: flex; justify-content: center; align-items: center; flex-direction: column; } .tab-bar-item cover-image { width: 27px; height: 27px; } .tab-bar-item cover-view { font-size: 10px; } 效果: [图片]
2022-03-08