File tree Expand file tree Collapse file tree
webpack-plugin/lib/runtime/components/react Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -225,7 +225,7 @@ module.exports = {
225225在 RN 环境下使用 ` selectComponent ` 或 ` selectAllComponents ` 时,必须在目标节点上标记 wx: ref 。选择器支持范围有限,仅支持以下方式
226226 * id 选择器:` #id `
227227 * class 选择器(可连续指定多个):` .a-class ` 或 ` .a-class.b-class.c-class `
228-
228+
229229``` javascript
230230< template>
231231 <!-- 必须添加 wx: ref 标记 -->
@@ -277,7 +277,7 @@ Mpx 提供 `@mpxjs/webview-bridge` 来实现 H5 页面与 RN 应用的双向通
277277## 高级特性 {#advanced-features}
278278
279279` rnConfig ` 是 Mpx 框架专为 React Native 环境提供的配置对象,用于定制 RN 平台特有的行为和功能。通过 ` mpx.config.rnConfig ` 可以配置异步分包、分享、路由控制、屏幕适配等高级特性。
280-
280+
281281### 异步分包 {#async-subpackage}
282282
283283Mpx 在 RN 环境下实现了与微信小程序同等的异步分包功能,支持按需加载分包内容。基础使用可参考 [ 异步分包指南] ( https://www.mpxjs.cn/guide/advance/async-subpackage.html )
@@ -350,7 +350,7 @@ mpx.config.rnConfig.onLazyLoadPageError = (error) => {
350350
351351#### 自定义兜底页面 {#custom-fallback-page}
352352
353- 对于异步分包页面加载失败的情况会展示默认兜底页面,用户可以点击兜底页面底部的重试按钮重新加载异步分包页面。那么对于开发者提供的自定义的 fallback 兜底页面,框架会自动给自定义页面注入一个 ` onReload ` 方法以供开发者做页面重试的操作,具体见下方示例:
353+ 对于异步分包页面加载失败的情况会展示默认兜底页面,用户可以点击兜底页面底部的重试按钮重新加载异步分包页面。那么对于开发者提供的自定义的 fallback 兜底页面,框架会自动给自定义页面注入一个 ` reload ` 方法以供开发者做页面重试的操作,具体见下方示例:
354354
355355``` html
356356<template >
@@ -364,12 +364,9 @@ mpx.config.rnConfig.onLazyLoadPageError = (error) => {
364364import { createComponent } from ' @mpxjs/core'
365365
366366createComponent ({
367- props: {
368- onReload: Function // 框架自动注入
369- },
370367 methods: {
371368 handleRetry () {
372- this .onReload ? .( ) // 触发重新加载
369+ this .triggerEvent ( ' reload ' ) // 触发重新加载,reload 事件为框架自动注入
373370 }
374371 }
375372})
Original file line number Diff line number Diff line change @@ -373,7 +373,7 @@ export interface RnConfig {
373373 * @param params.package 分包名
374374 * @returns Promise,表示加载完成
375375 */
376- loadChunkAsync ?: ( params : { url : string ; package : string } ) => Promise < any >
376+ loadChunkAsync ?: ( params : { url : string ; package : string } ) => Promise < null >
377377
378378 /**
379379 * 下载多个异步分包的方法(不执行)。
Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ const styles = StyleSheet.create({
5656
5757interface DefaultFallbackProps {
5858 onReload : ( ) => void
59+ bindreload : ( ) => void
5960}
6061
6162const DefaultFallback = ( { onReload } : DefaultFallbackProps ) => {
@@ -171,7 +172,7 @@ const AsyncSuspense: React.FC<AsyncSuspenseProps> = ({
171172 } else if ( status === 'error' ) {
172173 if ( type === 'page' ) {
173174 const fallback = getFallback ? getFallback ( ) : DefaultFallback
174- return createElement ( fallback as ComponentType < DefaultFallbackProps > , { onReload : reloadPage } )
175+ return createElement ( fallback as ComponentType < DefaultFallbackProps > , { onReload : reloadPage , bindreload : reloadPage } )
175176 } else {
176177 return getFallback ? createElement ( getFallback ( ) , innerProps ) : null
177178 }
You can’t perform that action at this time.
0 commit comments