Files
lucky_shop/docs/weixin-bug.md

15 KiB
Raw Blame History

console.log

无效的 app.json permission["scope.userClipboard"]、app.json permission["scope.camera"]、app.json permission["scope.writePhotosAlbum"]
pages_tool/recharge/list: 无效的 page.json ["scrollEnabled"]

vendor.js:3 wx.getSystemInfoSync is deprecated.Please use wx.getSystemSetting/wx.getAppAuthorizeSetting/wx.getDeviceInfo/wx.getWindowInfo/wx.getAppBaseInfo instead.

[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components/register-reward/register-reward.wxss:2:429)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components/ns-login/ns-login.wxss:1:1448)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components/hover-nav/hover-nav.wxss:2:304)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components/ns-copyright/ns-copyright.wxss:1:1114)
无效的 app.json permission["scope.userClipboard"]、app.json permission["scope.camera"]、app.json permission["scope.writePhotosAlbum"]
pages_tool/recharge/list: 无效的 page.json ["scrollEnabled"]

[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-channel-video.wxss:1:7941)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-channel-list.wxss:1:3415)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-tab.wxss:1:6056)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components/ns-goods-sku/ns-goods-sku-category.wxss:2:67)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-category.wxss:1:8372)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-category-item.wxss:1:8672)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-bottom-nav.wxss:1:1634)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-video-list.wxss:1:7343)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-audio.wxss:1:249)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-hot-area.wxss:1:200)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-payment-qrcode.wxss:1:2077)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-quick-nav.wxss:1:447)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-member-my-order.wxss:1:385)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-member-info.wxss:6:4119)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-merch-list.wxss:1:2221)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-article.wxss:1:2941)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-goods-recommend.wxss:4:1240)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-fenxiao-goods-list.wxss:1:4000)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-live.wxss:1:146)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-float-btn.wxss:1:544)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-notes.wxss:1:2367)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-presale.wxss:1:1955)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-bargain.wxss:1:5456)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-pinfan.wxss:1:3083)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-groupbuy.wxss:1:2069)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-pintuan.wxss:1:6513)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-seckill.wxss:1:10928)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-rubik-cube.wxss:1:171)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-many-goods-list.wxss:1:963)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components/ns-form/ns-form.wxss:1:2545)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components/ns-goods-sku/ns-goods-sku.wxss:1:3373)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-goods-list.wxss:1:16746)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-coupon.wxss:2:1656)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-search.wxss:1:1052)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-img-ads.wxss:1:1009)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-notice.wxss:1:1282)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-text.wxss:1:9199)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components/ns-newform/ns-newform.wxss:3:3187)
[pages/index/index] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./components-diy/diy-store.wxss:1:1985)

[WXML Runtime warning] ./components-diy/diy-picture.wxml
 Now you can provide attr `wx:key` for a `wx:for` to improve performance.
> 1 | <view class="diy-picture" style="{{(style)}}" data-component-name="diy-picture"><view class="fui-picture"><block wx:for="{{$root.l0}}" wx:for-item="item" wx:for-index="index"><view style="line-height:0;"><block wx:if="{{item.$orig.link.wap_url}}"><image style="width:100%;height:auto;" mode="widthFix" src="{{item.g0}}" show-menu-by-longpress="{{true}}" data-event-opts="{{[['tap',[['handlerClick',['$0'],[[['value.list','',index]]]]]]]}}" catchtap="__e"></image></block><block wx:else><image style="width:100%;height:auto;" mode="widthFix" src="{{item.g1}}" show-menu-by-longpress="{{true}}" data-event-opts="{{[['tap',[['handlerClick',['$0'],[[['value.list','',index]]]]]]]}}" catchtap="__e"></image></block></view></block></view><ns-login class="vue-ref" vue-id="103d5f85-1" data-ref="login" bind:__l="__l"></ns-login></view>
    |                                                                                                           ^
[Deprecation] SharedArrayBuffer will require cross-origin isolation as of M92, around July 2021. See https://developer.chrome.com/blog/enabling-shared-array-buffer/ for more details.

无使用或无依赖文件

不应存在无使用的组件
components/mescroll/components/mescroll-empty.json

模拟器与真机行为差异备忘

涉及 navigationBar / 标题栏 / web-view 的逻辑,必须在真机调试,模拟器结果不可信。

能力 / API 真机 微信开发者工具模拟器 备注
uni.setNavigationBarTitle 立即生效 不生效(一直存在的 bug) 模拟器不执行本地实现
<web-view @titleUpdate> 不触发 不触发 mp 端不支持此事件,仅 H5 可用
navigationBar 标题来源 setNavigationBarTitle 调用 / pages.json.navigationBarTitleText 仅 pages.json.navigationBarTitleText 模拟器无 fallback,写了也看不到
标题初始值(H5) manifest.json 的 name / h5.title 同左 与 mp 无关
<web-view @load> (mp) 加载成功后触发 触发正常 真机模拟器行为一致

已踩过的坑

1. webview.vue 标题在模拟器永远显示 "加载中..."

症状:在 WeChat 开发者工具模拟器里打开 pages_tool/webview/webview,navigationBar 始终是 manifest.json 的 "name": "加载中...",传 enable_set_title=1&title=真实标题 也没用。

根因:模拟器不执行 uni.setNavigationBarTitle 的本地实现,只读 pages.json 里的 navigationBarTitleText(当前为空字符串),最终落到 manifest.json 的 name 兜底。

正确处理:

  • 代码保持简单,单次 setNavigationBarTitle 即可,不要加 @load 兜底、不要加定时器重试、不要模拟器专用 workaround。
  • 必须在真机验证标题行为;模拟器结果不可信。

2. mp 端 <web-view> 不会触发 @titleUpdate

症状:在 pages_tool/webview/webview.vue 里写 @titleUpdate="updateNavbarTitle",期望内嵌页 <title> 变化时自动同步 navigationBar,但 mp 端完全不触发。

根因:WeChat <web-view> 原生组件不支持 titleUpdate 事件,@titleUpdate 只在 H5(uni-app 用 iframe 模拟)下生效。

正确处理:

  • mp 端标题必须由 uni.setNavigationBarTitle 在 onLoad / onShow 显式写入。
  • 想拿内嵌页真实 <title>,让内嵌页通过 jweixin 调 wx.miniProgram.setNavigationBarTitle 反向通知;或者干脆不用"显示内嵌页标题"这个需求,直接由 query 参数传固定标题。

3. 不要为模拟器 bug 写 workaround

有些"修模拟器表现"的尝试(@load 多次重试 setNavigationBarTitle、加看门狗定时器)会让真机代码变得复杂、可能和内嵌页 document.title 抢控制权、引入边界 case。

结论:遇到 navigationBar / web-view 相关问题,先在真机上复现确认;只在真机还在问题再继续查代码。

4. setClipboardData:fail api scope is not declared in the privacy agreement

症状:AI 智能(pages_tool/ai-chat)复制消息时 Toast 提示 复制失败:setClipboardData:fail api scope is not declared in the privacy agreement, H5 正常,只有微信小程序失败。

根因:微信自 2023-09-15 起把剪贴板接口(setClipboardData / getClipboardData)纳入 《小程序用户隐私保护指引》。小程序后台未声明「剪贴板」,或声明还在审核中时,调用直接失败, 返回 errno: 112。这是平台侧配置问题,不是代码问题: app.json 的 permission / requiredPrivateInfos 都不涉及剪贴板,改代码无法绕过。

正确处理:

  • 微信公众平台 → 设置 → 基本设置 → 服务内容声明 → 用户隐私保护指引 → 更新 → 在「开发者收集你的……信息」中勾选「剪贴板」并填写用途 → 提交审核; 审核通过后才生效,通过后重新编译/发版即恢复。
  • 代码侧只做兜底:common/js/uniapp.utils.js 的 isClipboardPrivacyError() 识别 errno === 112 / errMsg 含 privacy agreement,用 i18n 文案替换微信原始英文错误 (AI 聊天页 copyMessage 同样处理),不要把平台英文报错抛给用户。
  • 开发期想临时绕过校验:把 manifest.json → mp-weixin → "__usePrivacyCheck__" 改成 false (仅限本地调试,上线前必须还原,并按上面的后台配置完成声明)。

注意:根目录的 privacy.json(内容为 Scope.writeClipboard)不是微信的隐私声明机制, 未被任何代码或构建流程引用,不要把它当成剪贴板隐私的解决方案。

代码侧备选(无法改后台、只想先跑起来时):

  • 写剪贴板在微信里只有 wx.setClipboardData 这一个 JS API,平台拦截 errno 112 时任何代码都绕不过, 所以「复制」按钮在没声明剪贴板权限前必然失败。
  • AI 回复的展示走 <rich-text> 富文本(豆包风格:加粗标题、悬挂缩进列表、彩色链接),由 parseMarkdown() 生成 HTML、getAIDisplayContent() 输出,H5 用 v-html、微信小程序用 <rich-text :nodes>。
  • 富文本不可长按选区复制(微信 rich-text 不支持),复制只能走「复制」按钮(即 wx.setClipboardData), 因此必须声明剪贴板权限,或开发期把 manifest.json → mp-weixin → "__usePrivacyCheck__" 改 false (仅本地调试,上线前必须还原)。
  • 失败时提示会引导用户复制不可用(isClipboardPrivacyError() 识别 errno 112)。