Comments (6)
经历了一整天的摸索(还是排除法最好用),问题终于得到解决了。感谢 @watsonhaw5566 兄弟的指导。
问题原因
导致我出现onShareAppMessage、onShareTimeline并不是官方库的问题,按照官方文档的使用方法是能够正常实现转发和分享至朋友圈功能的。
也不是babel.config.js的presets配置问题。
而我本地失败的原因是两个地方:
- 因为在编写组件的时候,有些组件没有引入
import React from 'react';
,即使你导入和react
,React
还是必须要写;
注意,是所有UI组件必须都要导入
react
。
// 正确导入
import React from 'react';
import React, { useEffect, useState } from 'react';
//错误导入
没有导入`react`
import { useEffect, useState } from 'react';
- 在我的
Container.js
组件中使用了hideShareMenu()
方法获取页面路由,导致react运行失败。
//Container关键代码
import { View, hideShareMenu } from 'remax/wechat';
...
const [path, setPath] = useState();
useEffect(() => {
// eslint-disable-next-line no-undef
const pages = getCurrentPages();
if (pages && pages?.length > 0) {
const path = pages?.[pages.length - 1]?.route;
// 此行代码会产生「错误边界」问题,因此注释了
// if (!canShare) hideShareMenu?.();
setPath(path);
}
}, []);
以上两个因素导致失败的本质原因是程序在运行时,遇到上诉两种错误,产生「错误边界」导致的。
所以我针对上面两个原因,调整代码后,程序就正常跑通了,开心~
希望能够帮助到遇到同类问题的小伙伴~
from remax.
我猜测你配置的 babel preset remax 覆盖了原有的 remax preset ,
remax 的 onShareAppMessage onShareTimeline 是正常运行的, 检查一下自己的 preset 配置。
from remax.
我猜测你配置的 babel preset remax 覆盖了原有的 remax preset , remax 的 onShareAppMessage onShareTimeline 是正常运行的, 检查一下自己的 preset 配置。
我就是安装官网的例子配置的,我也不知道哪里出现问题了。我现在都无从下手了~
from remax.
移除 babel 的配置,再跑一次
from remax.
移除 babel 的配置,再跑一次
移除跑,报下面的错误了
from remax.
先删除一下 babel.config.js ,删除 dist 目录,再跑一次。
from remax.
Related Issues (20)
- 文档官网域名到期,正在想办法~ HOT 11
- [问题]标签上的TS2559报错信息 HOT 2
- npx create-remax-app my-app 命令执行失败,无法创建项目 钉钉群也失效了? HOT 1
- [BUG] `@remax/web` 未导出 `renderLanding方法`或未实现该方法 HOT 1
- 是不是打算直接废弃这个项目??冷处理 HOT 8
- [样式错乱]每个View组件的样式前都有个a-view,导致样式都被覆盖了。在微信是好的。在支付宝就不行了。麻烦问下是什么情况 HOT 1
- [需求] eslint 可以安排一下吗?可以再脚手架里面 编写代码的时候自动识别 HOT 1
- [需求]
- [BUG] remax 文档网站部署访问报错 HOT 1
- 其实remax开发很爽的,可惜不投入了 HOT 3
- 这个框架后续还会维护吗? HOT 7
- [问题] 微信小程序头像与能力填写能力支持 HOT 1
- remax build -w -t wechat 启动的小程序,引用的小程序原生组件会报Component is not found in path HOT 4
- 远程请求打包为umd格式的react组件,然后热更新微信小程序页面,该如何实现呢? HOT 1
- 如何在打包过程中往mini.prject.json注入内容
- App 上的基础组件现在是不会渲染的,也就是说下面的 View 是不会渲染到页面上的。 HOT 1
- [问题]什么时候能再发一版正式版本,现在新的api兼容每次都要修改node_modules HOT 1
- [需求]不支持 react-router v6
- [问题]怎么把所有的分包样式都打包到主包的remax-styles.wxss里面
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from remax.