uni-app微信小程序暂不支持report ???

uni-app微信小程序暂不支持report ???

问题描述

只要用这个组件就报这个错误?什么情况??

代码

<uni-nav-bar title="推荐" class="custom-bar" :backgroundColor="navBarBackgroundColor" :color="navbarcolor"  
        fixed="true" statusBar :border="false"></uni-nav-bar>
const navBarBackgroundColor = ref('rgba(0,0,0,0)');  
const navbarcolor = ref("#333")  
onPageScroll((e) => {  
    if (e.scrollTop > 0) {  
        navBarBackgroundColor.value = "rgba(0,0,0,0.05)"  
        navbarcolor.value = "#fff"  

    } else if (e.scrollTop === 0) {  
        navBarBackgroundColor.value = "rgba(0,0,0,0)"  
        navbarcolor.value = "#333"  
    }  
})

错误信息

index.esm.js:39 微信小程序 暂不支持report(env: Windows,mp,1.06.2412050; lib: 3.7.7)

看起来没多大毛病啊??为啥打包小程序报错?只要删除这个组件就恢复正常了


更多关于uni-app微信小程序暂不支持report ???的实战教程也可以访问 https://www.itying.com/category-93-b0.html

4 回复

我测试了下 用这个组件没出现报错哦 你是不是其他地方的代码影响到这个组件了?能发个复现demo吗?

更多关于uni-app微信小程序暂不支持report ???的实战教程也可以访问 https://www.itying.com/category-93-b0.html


我今天也看到了,问题已定位就是使用title的参数的时候.

我也遇到了,使用uni-nav-bar,传参title的时候就会出现

这个错误是由于uni-app在微信小程序环境中不支持report功能导致的。uni-nav-bar组件在微信小程序平台下会尝试调用report接口,但该接口在小程序环境中不可用。

解决方案:

  1. 最简单的办法是使用微信小程序原生导航栏代替uni-nav-bar:
// pages.json中配置
{
  "pages": [{
    "path": "pages/index/index",
    "style": {
      "navigationBarTitleText": "推荐",
      "navigationBarTextStyle": "black",
      "navigationBarBackgroundColor": "#ffffff"
    }
  }]
}
  1. 如果必须使用uni-nav-bar,可以添加条件编译:
// #ifndef MP-WEIXIN
<uni-nav-bar title="推荐" class="custom-bar" 
  :backgroundColor="navBarBackgroundColor" 
  :color="navbarcolor"  
  fixed="true" statusBar :border="false">
</uni-nav-bar>
// #endif
  1. 也可以检查uni-app版本,升级到最新版可能已修复此问题:
npm update [@dcloudio](/user/dcloudio)/uni-ui
回到顶部