Skip to content
Open
Show file tree
Hide file tree
Changes from 216 commits
Commits
Show all changes
294 commits
Select commit Hold shift + click to select a range
6d22397
feat: add sticky-section 配置
Mar 3, 2025
156d402
Merge branch 'master' into feat-extend-sticky
Mar 3, 2025
4c7e647
chore: add sticky section config
Mar 4, 2025
5b1e320
fix: rn 吸顶逻辑计算
Mar 4, 2025
fe3dc93
feat: 支持padding属性
Mar 4, 2025
a325f03
fix: 导航条位置获取异常导致吸附位置不正确
Mar 5, 2025
93e0a07
feat: add sticky-section组件
Mar 5, 2025
63e6ea9
Merge branch 'master' into feat-recycle-list-web
Mar 5, 2025
a579c70
Merge branch 'master' into feat-extend-sticky
Mar 5, 2025
0d2484d
chore: 删除无用sticky组件
Mar 5, 2025
d7c7089
Merge branch 'master' into feat-extend-sticky
Mar 7, 2025
666202c
Merge branch 'master' into feat-recycle-list-web
Mar 7, 2025
438aed5
Merge branch 'feat-recycle-list-web' into feat-extend-sticky
Mar 7, 2025
09cc262
fix: add enableSticky 属性
Mar 7, 2025
3e89590
chore: del useless code
Mar 7, 2025
a4a9ba2
Merge branch 'feat-recycle-list-web' into feat-extend-sticky
Mar 7, 2025
a05fda4
fix: sticky-header
Mar 7, 2025
15dd08b
fix: AnimatedScrollView 生成时机
Mar 14, 2025
8f2b0a6
fix: AnimatedScrollView 生成时机
Mar 14, 2025
b3671e7
Merge branch 'master' into feat-extend-sticky
Mar 14, 2025
1f9ad4c
chore: 调整组件入参
Mar 14, 2025
371ccf8
fix: lint
Mar 14, 2025
ec78dde
Merge branch 'master' into feat-extend-sticky
Mar 18, 2025
9680227
fix: 外层做动画 android pageY 可能拿到不准问题
Mar 19, 2025
ae22a6c
Merge branch 'master' into feat-extend-sticky
Mar 21, 2025
c2eef9d
chore: 修改scroll触发逻辑
Mar 21, 2025
2ec66c0
chore: 修改scroll触发逻辑
Mar 21, 2025
4d7a2d2
chore: 修改 aboveCount 和 belowCount 计算逻辑
Mar 21, 2025
f311836
Merge branch 'feat-simple-view' into feat-extend-sticky
Mar 21, 2025
26d4413
Merge branch 'feat-simple-view' into feat-extend-sticky
Mar 21, 2025
730736d
chore: 调整组件重建时机
Mar 21, 2025
c29beeb
feat: 支持scrollTo方法
Mar 21, 2025
24e9183
chore: 新增支持props
Mar 21, 2025
c35d1a9
Merge branch 'feat-simple-view' into feat-extend-sticky
Mar 21, 2025
b178e62
Merge branch 'feat-simple-view' into feat-extend-sticky
Mar 21, 2025
15d84ee
Merge branch 'feat-simple-view' into feat-extend-sticky
Mar 24, 2025
d12815d
chore: add rn recyle
Mar 24, 2025
b9ce382
feat: 支持generic
Mar 24, 2025
b408c80
chore: 修改generic
Mar 25, 2025
0bd9f71
chore: 修改generic
Mar 25, 2025
d024f47
chore: 修改generic
Mar 25, 2025
7b87ad6
chore: 修改injectProperties注入时机
Mar 25, 2025
bf6d32f
fix: boundingClientRect 获取异常
Mar 25, 2025
a187e38
Merge branch 'feat-extend-sticky' into feat-generic-rn
Mar 25, 2025
acdefe2
chore: del
Mar 25, 2025
31d64fc
Merge branch 'feat-simple-view' into feat-extend-sticky
Mar 25, 2025
35b1fe3
Merge branch 'feat-generic-rn-new' into feat-extend-sticky
Mar 26, 2025
d64e552
Merge branch 'feat-extend-sticky' into feat-recycle-rn
Mar 26, 2025
a3f6a70
fix conflict
Mar 26, 2025
7d02911
Merge branch 'feat-extend-sticky' into feat-recycle-rn
Mar 26, 2025
6ec3a9c
chore: 增强recycle-view.
Mar 26, 2025
596026f
Merge branch 'feat-generic-rn-new' into feat-recycle-rn
Mar 26, 2025
0dc180b
Merge branch 'master' into feat-recycle-rn
Mar 30, 2025
5daf649
Merge branch 'feat-generic-rn-new' into feat-recycle-rn
Mar 30, 2025
5b51763
chore: 修改recycle逻辑
Mar 30, 2025
02fc308
Merge branch 'feat-generic-rn-new' into feat-recycle-rn
Mar 31, 2025
9ba79c9
Merge branch 'master' into feat-recycle-rn
Mar 31, 2025
28ed166
chore: 修改文件路径
Apr 1, 2025
83bb124
Merge branch 'feat-generic-rn-new' into feat-recycle-rn
Apr 1, 2025
ad11b1a
Merge branch 'master' into feat-recycle-rn
Apr 1, 2025
798a1cf
Merge branch 'master' into feat-recycle-rn
Apr 10, 2025
4f409dc
fix: lint;
Apr 11, 2025
f5fcefe
feat: 补充recycle能力
Apr 11, 2025
5148785
feat: 优化小程序 recycle-view
Apr 15, 2025
835368b
chore: 调整recycle目录
Apr 15, 2025
760dccd
Merge branch 'feat-sticky-rn' into feat-recycle-rn
Apr 15, 2025
0ce6847
feat: 支持 rn 环境recycle
Apr 16, 2025
c192ec0
chore: rn环境支持recycle-view
Apr 17, 2025
de646d4
chore: rn环境支持recycle-view
Apr 17, 2025
0ab5792
chore: 调试recycle
Apr 21, 2025
48a2364
chore: 调试recycle
Apr 21, 2025
d207cdd
chore: 调试getSectionItemLayout
Apr 23, 2025
1e764fa
chore: 调试getSectionItemLayout
Apr 24, 2025
c42ac70
chore: 调试getSectionItemLayout
Apr 25, 2025
fb36889
chore: 调试getSectionItemLayout
Apr 25, 2025
af7d0b6
chore: 兼容flatList
Apr 25, 2025
1e2f722
chore: 支持scrollToIndex
Apr 25, 2025
25263d7
chore: 支持反向索引映射
Apr 25, 2025
5f23489
Merge branch 'master' into feat-recycle-rn
Apr 27, 2025
cbd6b1b
feat: 优化小程序recycle
Apr 27, 2025
cd5100a
feat: 优化小程序recycle
Apr 27, 2025
18f8552
feat: 优化小程序recycle
Apr 28, 2025
be207ec
chore: 修改recycle注入逻辑
Apr 28, 2025
b8407da
chore: 修改rn组件注入条件
Apr 29, 2025
a7f38c6
chore: rn环境支持通过ref获取scrollToIndex方法
Apr 29, 2025
011f8e5
fix: wx recycle
Apr 29, 2025
3ee2cc6
chore: 调整wx组件结构
Apr 29, 2025
3a725d2
chore: del 无用md
Apr 30, 2025
bdfd315
Merge branch 'feat-sticky-rn' into feat-recycle-rn
Apr 30, 2025
2b04cc0
chore: 调整ali,web组件注入逻辑
Apr 30, 2025
68b60bf
Merge branch 'master' into feat-recycle-rn
May 7, 2025
b2f151d
feat: 支持 web sticky;
May 7, 2025
e575ba8
feat: 支持scrollToIndex
May 8, 2025
b7993c2
feat: 支持下拉刷新
May 8, 2025
548ac5e
feat: 支持list-header
May 8, 2025
51051ba
chore: 使用enableSticky作为标识
May 8, 2025
811658a
Merge branch 'feat-recycle-rn' into feat-recycle-sticky-web
May 8, 2025
5fcc341
chore: 优化组件注册逻辑
May 8, 2025
5305a48
feat: scrollToIndex支持viewPosition
May 8, 2025
eedc1fc
chore: 优化props类型
May 9, 2025
043752b
chore: 优化props类型
May 9, 2025
c366c40
chore: 优化props类型
May 9, 2025
2c801b1
Merge branch 'feat-recycle-rn' into feat-recycle-sticky-web
May 9, 2025
6eba2d4
chore: 优化props类型
May 9, 2025
8fc3515
chore: 优化组件注册逻辑
May 9, 2025
169e428
chore: 调整mpx-recycle-view目录
May 9, 2025
8f60230
chore: 调整mpx-recycle-view目录
May 9, 2025
3000d00
Merge branch 'feat-recycle-rn' into feat-recycle-sticky-web
May 9, 2025
570667f
Merge branch 'feat-sticky-rn' into feat-recycle-rn
May 12, 2025
a937a57
feat: init sticky ali
May 13, 2025
b7468e9
feat: init sticky ali
May 13, 2025
b0211f0
Merge branch 'feat-sticky-rn' into feat-recycle-rn
May 21, 2025
15895f3
Merge branch 'feat-sticky-rn' into feat-recycle-sticky-web
May 21, 2025
4c8cb27
Merge branch 'feat-sticky-rn' into feat-sticky-ali
May 22, 2025
2505b65
feat: 切换sticky吸附判断条件
May 23, 2025
1386c9e
fix: offsetTop导致吸附位置错误问题
May 23, 2025
deb6e01
feat: ali环境支持sticky-section
May 26, 2025
f7d80fa
Merge branch 'feat-sticky-rn' into feat-recycle-rn
May 26, 2025
e8732eb
Merge branch 'feat-recycle-rn' into feat-sticky-ali
May 26, 2025
c633673
chore: ali 支持recycle-view
May 26, 2025
e59c1cd
chore: 优化recycle-view
May 27, 2025
02dfc1f
chore: 优化sticky
May 27, 2025
47807f1
Merge branch 'master' into feat-sticky-ali
May 27, 2025
ccc8ac5
chore: 优化recyle
May 28, 2025
9bea494
chore: 优化recyle
May 28, 2025
d104685
chore: 修改recycle-view ref 获取返回值
May 28, 2025
9e15b94
Merge branch 'feat-recycle-rn' into feat-sticky-ali
May 28, 2025
e75566a
chore: 补充ali环境EXTEND_COMPONENTS_LIST
May 28, 2025
d77cc56
chore: 补充ali环境EXTEND_COMPONENTS_LIST
May 28, 2025
3d32435
Merge branch 'feat-recycle-rn' into feat-sticky-ali
May 28, 2025
55fcfac
Merge branch 'feat-recycle-rn' into feat-recycle-sticky-web
May 28, 2025
e423ba8
chore: 优化sticky-header
May 29, 2025
c9f2aad
chore: 添加轮询修正逻辑
May 29, 2025
bd54ba0
chore: 添加轮询修正逻辑
May 29, 2025
6e2262d
Merge branch 'master' into feat-recycle-rn
Jun 18, 2025
8053a33
Merge branch 'master' into feat-recycle-sticky-web
Jun 18, 2025
bc953eb
Merge branch 'master' into feat-sticky-ali-v2
Jun 20, 2025
69ea628
chore: 优化refresh逻辑
Jun 20, 2025
a178120
chore: 优化handleStickyStateChange逻辑
Jun 20, 2025
358058f
Merge branch 'master' into feat-recycle-rn
Sep 3, 2025
23312fb
chore: cr修改
Sep 5, 2025
2adde6e
refactor: flatlist替换为sectionlist
Sep 16, 2025
5c8cfd7
feat: 拓展组件注册考虑单组件输出
Sep 16, 2025
f6d519e
chore: 修改默认组件样式
Sep 17, 2025
6f10b44
Merge pull request #2224 from didi/feat-recycle-rn-cr
yandadaFreedom Sep 17, 2025
b197c4a
Merge branch 'master' into feat-recycle-rn
Sep 17, 2025
4e83ff6
feat: 新增end-reached-threshold属性
Sep 18, 2025
37751fc
feat: web增加原生组件titlebar&页面支持开启titlebar
mackwang112 Oct 17, 2025
efd114a
feat: web增加原生组件titlebar
mackwang112 Oct 17, 2025
9d945d8
Merge branch 'feat-recycle-rn' into feat-recycle-sticky-web
Nov 21, 2025
e659668
Merge branch 'master' into feat-recycle-sticky-web
Nov 21, 2025
9ea4fe4
fix: web recycle-view 格式与其他平台拉齐
Nov 21, 2025
6a7d6ba
Merge branch 'feat-recycle-rn' into feat-sticky-ali-v2
Nov 21, 2025
86f0ed8
Merge branch 'feat-recycle-sticky-web' into feat-sticky-ali-v2
Nov 21, 2025
7e604f0
chore: 修改web注册拓展组件逻辑
Nov 24, 2025
d2e1435
Merge branch 'feat-recycle-sticky-web' into feat-sticky-ali-v2
Nov 24, 2025
84d5b03
chore: 优化ali环境recyle-view渲染逻辑
Nov 24, 2025
996ff5d
docs: 补充recycle-view文档
Nov 24, 2025
8705b49
docs: 补充recycle-view文档
Nov 24, 2025
f7bf9cc
docs: 补充recycle-view文档
Nov 24, 2025
186aba6
docs: 补充文档
Dec 1, 2025
1878280
docs: 补充文档
Dec 1, 2025
e331c77
fix: 外层容器定高,recycle-view无法滚动问题
Dec 1, 2025
e975878
Merge branch 'feat-recycle-sticky-web' into feat-sticky-ali-v2
Dec 1, 2025
b9ba9d1
docs: 补充文档
Dec 1, 2025
4eef437
Merge branch 'master' into feat-sticky-ali-v2
Dec 1, 2025
d2afd25
Merge branch 'master' into feat-recycle-rn
Dec 1, 2025
5d48042
fix: lint error
Dec 1, 2025
30bb85d
chore: 修改useListHeader默认值
Dec 1, 2025
15831f6
chore: 修改useListHeader默认值
Dec 1, 2025
71407a0
chore: 修改useListHeader默认值
Dec 1, 2025
5b6f2ca
docs: 补充文档
Dec 1, 2025
e0c4401
docs: 修改文档
Dec 1, 2025
197708c
fix: 动态修改height相关配置,重新触发getItemLayout计算
Jan 12, 2026
87c50a2
fix: sectionList 重新渲染导致list-item、list-header 等组件 销毁并重新创建;
Jan 15, 2026
5b5d2d2
Merge pull request #2404 from didi/feat-sticky-ali-v2-cr
yandadaFreedom Jan 19, 2026
c097ef3
feat: 修复recycle-view组件渲染导致item等组件销毁重建&支持list-footer节点
Jan 22, 2026
5ca823b
fix: conflict;
Jan 22, 2026
1655db9
feat: wx & web支持list-footer节点&支持itemHeight等高度动态变化
Jan 22, 2026
8be6bc2
feat: ali支持list-footer节点&支持itemHeight等高度动态变化
Jan 22, 2026
2388fd4
feat: scrollToIndex 支持 viewOffset参数
Jan 22, 2026
1de2850
refactor: 重构拓展组件引用机制
Jan 23, 2026
c57abd7
feat: 新增通过key复用dom机制,https://
Jan 23, 2026
1a5507f
refactor: 修改sticky相关组件注册机制
Jan 23, 2026
ca7772c
Merge branch 'master' into feat-sticky-ali-v2
Jan 23, 2026
e798421
feat: add defult generics component
Jan 23, 2026
fbe97cf
chore: rename recycle-list
Jan 28, 2026
e491f1b
fix: lint error
Jan 28, 2026
3d4109d
feat: 添加拓展组件占位文件
Feb 2, 2026
71fe3bc
Merge branch 'master' into feat-sticky-ali-v2
Feb 26, 2026
539e691
v2.10.18-beta.1
Blackgan3 Mar 5, 2026
8bece5f
fix: 修复strip-conditional条件执行问题
Blackgan3 Mar 9, 2026
6119657
v@mpxjs/webpack-plugin@2.10.18-beta.2
Blackgan3 Mar 10, 2026
fc04808
fix(input): 修复输入框特定失焦场景
wangshunnn Mar 10, 2026
749e3d3
v@mpxjs/webpack-plugin@2.10.18-beta.3
Blackgan3 Mar 10, 2026
9bdf8c0
Merge branch 'master' into feat-sticky-ali-v2
Mar 10, 2026
645f6e3
Merge pull request #2434 from didi/fix-drn-2.10.18-input
Blackgan3 Mar 11, 2026
a61c4f5
v2.10.18-beta.4
Blackgan3 Mar 11, 2026
587b687
del transform sort
wenwenhua Mar 13, 2026
c2b34ac
Merge pull request #2446 from didi/fix-drn-2.10.18-transform-order
Blackgan3 Mar 16, 2026
73318de
v@mpxjs/webpack-plugin@2.10.18-beta.5
Blackgan3 Mar 16, 2026
d3f0415
fix(pircker-view): sync offsetYShared with itemRawH for correct wheel…
wangshunnn Mar 17, 2026
2e1619a
Merge pull request #2447 from didi/fix-drn-2.10.18-picker-view
Blackgan3 Mar 18, 2026
7b73471
v:@mpxjs/webpack-plugin@2.10.18-beta.6
Blackgan3 Mar 23, 2026
ccd984b
v@mpxjs/webpack-plugin@2.10.18-beta.7
Blackgan3 Mar 24, 2026
41cda93
v:2.10.18-beta.8
Blackgan3 Mar 25, 2026
7717b2e
add transition duration
wenwenhua Apr 3, 2026
8049df8
transition 更新
wenwenhua Apr 9, 2026
a8d9f3a
Merge branch 'master' into feat-sticky-ali-v2
Apr 13, 2026
4414326
v@mpxjs/webpack-plugin@2.10.18-beta.5
Blackgan3 Mar 16, 2026
177bd51
fix(pircker-view): sync offsetYShared with itemRawH for correct wheel…
wangshunnn Mar 17, 2026
c3087f7
v:@mpxjs/webpack-plugin@2.10.18-beta.6
Blackgan3 Mar 23, 2026
cde9ebb
v@mpxjs/webpack-plugin@2.10.18-beta.7
Blackgan3 Mar 24, 2026
615128b
v:2.10.18-beta.8
Blackgan3 Mar 25, 2026
252cce0
fix: 修复首页 global.__mpxEnterOptions.query 取值异常
mackwang112 Apr 14, 2026
f056da6
fix: 修复首页 global.__mpxEnterOptions.query 取值异常
mackwang112 Apr 14, 2026
8b46090
@mpxjs/core@2.10.18-beta.3
mackwang112 Apr 15, 2026
a1daa7a
[feat]remove asyncChunk timeout
CommanderXL Apr 16, 2026
19bf204
Merge pull request #2464 from didi/fix-drn-2.10.18-remove-asyncChunk-…
Blackgan3 Apr 16, 2026
ccbe5f2
Merge remote-tracking branch 'origin/fix-drn-2.10.18' into fix-drn-2.…
Blackgan3 Apr 16, 2026
3aadee6
v2.10.18-beta.8
Blackgan3 Apr 16, 2026
87d0219
Merge tag 'v2.10.18' into feat-web-title-bar
mackwang112 Apr 16, 2026
9aefe2f
fix: 移除注释
mackwang112 Apr 16, 2026
7fbd966
docs: 补充mpx.config.webConfig.enableTitleBar文档
mackwang112 Apr 16, 2026
dc38e11
Merge branch 'feat-web-title-bar' into fix-drn-2.10.18
mackwang112 Apr 16, 2026
bcfa42d
@mpxjs/webpack-plugin@2.10.18-beta.10
mackwang112 Apr 16, 2026
5fc72bf
web title bar
mackwang112 Apr 16, 2026
6438d0f
Merge branch 'fix-drn-2.10.18' into feat-web-title-bar
mackwang112 Apr 16, 2026
1bf20f5
feat: sectionList 支持手势协同
Apr 16, 2026
9bc8729
feat: 删除无用组件配置
Apr 16, 2026
4b5a554
feat: 删除无用组件配置
Apr 16, 2026
e4471e4
Merge branch 'feat-sticky-ali-v2' into feat-section-list-gesuture
Apr 16, 2026
1d74d32
update
wenwenhua Apr 20, 2026
2f98207
Merge branch 'fix-drn-2.10.18' into fix-drn-2.10.18-transition
wenwenhua Apr 25, 2026
d537b8a
add transition duration
wenwenhua Apr 25, 2026
ef2fb6d
Merge pull request #2458 from didi/fix-drn-2.10.18-transition
Blackgan3 Apr 27, 2026
635106e
@mpxjs/webpack-plugin@2.10.18-beta.11
mackwang112 Apr 28, 2026
2fb1125
Merge branch 'feat-web-title-bar' into fix-drn-2.10.18
mackwang112 Apr 28, 2026
de6f0b1
vbeta
Blackgan3 Apr 29, 2026
23fc767
支持observe可以传入refs
May 6, 2026
6d01e6b
Merge pull request #2477 from didi/feat-2.10.18-observerefs
Blackgan3 May 6, 2026
0dba55b
Merge remote-tracking branch 'origin/fix-drn-2.10.18' into fix-drn-2.…
Blackgan3 May 6, 2026
6c8110f
v@mpxjs/api-proxy@2.10.18-beta.12
Blackgan3 May 6, 2026
d2124a0
Merge branch 'master' into feat-sticky-ali-v2
May 11, 2026
7a82958
chore: 修复变量命名等问题
May 11, 2026
df1f636
Merge branch 'master' into fix-drn-2.10.18
Blackgan3 May 26, 2026
c05cbbc
Merge branch 'master' into feat-sticky-ali-v2
May 26, 2026
75b3a9c
Merge branch 'fix-drn-2.10.18' into feat-sticky-ali-v2
yandadaFreedom May 26, 2026
cb6adac
Merge branch 'master' into feat-sticky-ali-v2
Jun 2, 2026
3a9ddb8
Merge branch 'feat-sticky-ali-v2' of https://github.com/didi/mpx into…
Jun 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 81 additions & 58 deletions docs-vitepress/api/compile.md

Large diffs are not rendered by default.

173 changes: 173 additions & 0 deletions docs-vitepress/guide/extend/extend-component.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
# Mpx 扩展组件

除基础组件外,Mpx 额外提供一些扩展组件。扩展组件需开发者在 `mpx.config.js`中通过编译配置`useExtendComponents`按需注册,注册成功后即可作为全局自定义组件使用。
```js
// mpx.config.js
defineConfig({
pluginOptions: {
mpx: {
plugin: {
useExtendComponents: {
wx: ["recycle-view"],
ali: ["recycle-view"],
web: ["recycle-view"],
ios: ["recycle-view"],
android: ["recycle-view"],
harmony: ["recycle-view"]
}
}
}
}
})
```


## recycle-view

跨端虚拟列表组件,可自定义分组头、列表头、列表项,自动分段渲染兼容各端。

支持平台:微信小程序、支付宝小程序、Web、RN

### 属性

| 属性名 | 类型 | 默认值 | 说明 | 支持平台 |
|-----------------------|-------------|----------|------------------------|-----------|
| height | String/Number | 100% | 组件高度 | 全平台 |
| width | String/Number | 100% | 组件宽度 | 全平台 |
| listData | Array | [] | 列表数据,如需使用列表分组头 `section-header`,对应 item 的数据需要包含 `isSectionHeader: true` 标识 | 全平台 |
| enable-sticky | Boolean | false | 启用分组吸顶 | 全平台<br>⚠️微信小程序环境,需要使用 skyline 渲染模式,webview 模式不支持;web 环境仅支持移动端,不支持 pc 端 |
| scroll-with-animation | Boolean | false | 滚动动画 | 全平台 |
| generic:recycle-item | string | | 列表项,抽象节点组件名,对应组件需要通过 usingComponents 注册 | 全平台 |
| generic:section-header | string | | 列表分组头,抽象节点组件名,对应组件需要通过 usingComponents 注册 | 全平台 |
| generic:list-header | string | | 列表头,抽象节点组件名,对应组件需要通过 usingComponents 注册 | 全平台 |
| useListHeader | Boolean | false | 使用自定义列表头 | 全平台 |
| listHeaderData | Object | {} | 列表头数据 | 全平台 |
| itemHeight | Object | {} | 列表项高度配置(支持 getter/value),必须配置 | 全平台 |
| sectionHeaderHeight | Object | {} | 分组头部高度配置(getter/value),若使用了自定义分组头必须配置 | 全平台 |
| listHeaderHeight | Object | {} | 列表头部高度配置(getter/value),若使用了列表头必须配置 | 全平台 |
| bufferScale | Number | 1 | 渲染缓冲区行数(虚拟滚动优化) | 仅支付宝小程序/web支持 |
| minRenderCount | Number | 10 | 最小渲染项目数 | 仅支付宝小程序/web支持 |

#### `itemHeight`/`sectionHeaderHeight`/`listHeaderHeight` 格式说明

高度相关属性支持如下格式:

```js
height: {
value: 400, // 定高
getter: function (item, index) {
const seed = item.id % 2 || 0
const heights = [100, 300]
return heights[seed]
}
}
```

**说明:**
- `value`:默认高度(所有项相同高度时直接用 value 即可)。
- `getter`:函数形式,可接收每一项的数据和索引,按需返回不同高度(动态高度需求时使用)。
- `getter` 优先级 大于 value。

> 建议性能要求较高(如超大数据集)优先使用 `value` 定高。

### 事件

| 事件名 | 说明 | 支持平台 |
|-----------------------|-----------------------------------|--------------|
| bindscroll | 滚动时触发,返回滚动信息 | 全平台 |
| bindscrolltolower | 滚动到底部/触底通知 | 全平台 |
| bindscrollToIndex | 组件方法,滚动到指定索引 | 全平台 |

`scrollToIndex({ index, animated, viewPosition })` 参数说明:
- `index`:目标索引
- `animated`:是否滚动动画
- `viewPosition`:滚动定位,0:顶部, 0.5:中间, 1:底部

### 用法示例

```js
<recycle-view
generic:recycle-item="normal-recycle-item"
generic:section-header="section-header"
generic:list-header="list-header"
width="{{width}}"
height="{{height}}"
listData="{{dataList}}"
itemHeight="{{ itemHeight }}"
sectionHeaderHeight="{{headerHeight}}"
listHeaderHeight="{{listHeaderHeight}}"
bufferScale="{{bufferScale}}"
useListHeader="{{true}}"
enable-sticky="{{true}}"
/>
<script>
import mpx, { createPage, createComponent } from '@mpxjs/core'

const generateData = (itemsPerSection) => {
const data = []

for (let i = 0; i < 10; i++) {
data.push({
isSectionHeader: true, // 标识该行使用 section-header 对应的抽象节点渲染
title: `Section ${i + 1}`
})

// 添加该 section 的 items
for (let j = 0; j < itemsPerSection; j++) {
const itemNumber = i * itemsPerSection + j + 1
data.push({
id: itemNumber,
title: `Item ${itemNumber}`,
description: `This is item number ${itemNumber} in section ${i + 1}`
})
}
}
return data
}

createPage({
data: {
width: 0,
height: 0,
bufferScale: 5,
dataList: generateData(100),
itemHeight: {
getter: function (item, index) {
const seed = item.id % 2 || 0
const heights = [100, 300]
return heights[seed]
}
},
headerHeight: {
value: 50
},
listHeaderHeight: {
value: 100
}
},
onLoad() {
this.height = mpx.getWindowInfo().windowHeight
this.width = mpx.getWindowInfo().windowWidth
}
})
</script>
<script type="application/json">
{
"usingComponents": {
"normal-recycle-item": "@/components/recycle-item",
"section-header": "@/components/section-header",
"list-header": "@/components/list"
}
}
</script>
```

### 其它说明

- 当使用了列表项、列表头或者自定义分组头,必须配置对应 item/sectionHeader/listHeader 的 height 相关参数,否则会出现滚动异常情况。
- 可直接调用 ref 实例执行 `scrollToIndex` 方法实现滚动。
- 如果用户滑动的速度超过渲染的速度,则会先看到空白的内容,这是为了长列表优化不得不作出的妥协。
- 当某行滑出渲染区域之外后,其内部状态将不会保留。
- 在 RN 环境,recycle-view 通过 RN 提供的 SectionList 实现分组吸顶。受 RN 底层实现机制限制,开启 `enable-sticky` 且快速滑动时,自定义分组头有时会出现闪烁现象。此问题需要等待 RN 官方修复,我们会持续关注并跟进。
- 若某行需要使用 `section-header` 对应的抽象节点渲染,则该行数据必须包含 `isSectionHeader: true` 字段;否则默认使用 `recycle-item` 对应的抽象节点渲染

1 change: 1 addition & 0 deletions packages/webpack-plugin/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ class MpxWebpackPlugin {
// 若配置disableRequireAsync=true, 则全平台构建不支持异步分包
supportRequireAsync: !this.options.disableRequireAsync && (this.options.mode === 'wx' || this.options.mode === 'ali' || this.options.mode === 'tt' || isWeb(this.options.mode) || (isReact(this.options.mode) && this.options.rnConfig.supportSubpackage)),
partialCompileRules: this.options.partialCompileRules,
useExtendComponents: this.options.useExtendComponents,
collectDynamicEntryInfo: ({ resource, packageName, filename, entryType, hasAsync }) => {
const curInfo = mpx.dynamicEntryInfo[packageName] = mpx.dynamicEntryInfo[packageName] || {
hasPage: false,
Expand Down
19 changes: 18 additions & 1 deletion packages/webpack-plugin/lib/json-compiler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const createJSONHelper = require('./helper')
const RecordIndependentDependency = require('../dependencies/RecordIndependentDependency')
const RecordRuntimeInfoDependency = require('../dependencies/RecordRuntimeInfoDependency')
const { MPX_DISABLE_EXTRACTOR_CACHE, RESOLVE_IGNORED_ERR, JSON_JS_EXT } = require('../utils/const')
const { processExtendComponents } = require('../utils/process-extend-components')
const resolve = require('../utils/resolve')
const resolveTabBarPath = require('../utils/resolve-tab-bar-path')
const resolveMpxCustomElementPath = require('../utils/resolve-mpx-custom-element-path')
Expand Down Expand Up @@ -75,13 +76,17 @@ module.exports = function (content) {
const { getRequestString } = createHelpers(this)

let currentName

let hasApp = true
if (isApp) {
currentName = appInfo.name
} else {
currentName = componentsMap[resourcePath] || pagesMap[resourcePath]
}

if (!appInfo.name) {
hasApp = false

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const hasApp = !!appInfo.name 不就可以了

}

const relativePath = useRelativePath ? publicPath + path.dirname(currentName) : ''

const copydir = (dir, context, callback) => {
Expand Down Expand Up @@ -160,6 +165,18 @@ module.exports = function (content) {
json.usingComponents = json.usingComponents || {}
}

if (mode === 'wx' || mode === 'ali') {
const { useExtendComponents = {} } = mpx
if ((isApp || !hasApp) && useExtendComponents[mode]) {
const extendComponents = processExtendComponents({
useExtendComponents,
mode,
emitWarning
})
json.usingComponents = Object.assign({}, extendComponents, json.usingComponents)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这段逻辑感觉有点难维护,当前应该就遗漏了preprocessjson中的,要不然让用户自己注册使用吧

}
}

// 快应用补全json配置,必填项
if (mode === 'qa' && isApp) {
const defaultConf = {
Expand Down
21 changes: 20 additions & 1 deletion packages/webpack-plugin/lib/react/processJSON.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const { transSubpackage } = require('../utils/trans-async-sub-rules')
const createJSONHelper = require('../json-compiler/helper')
const getRulesRunner = require('../platform/index')
const { RESOLVE_IGNORED_ERR } = require('../utils/const')
const { processExtendComponents } = require('../utils/process-extend-components')
const RecordResourceMapDependency = require('../dependencies/RecordResourceMapDependency')
const RecordPageConfigsMapDependency = require('../dependencies/RecordPageConfigsMapDependency')

Expand All @@ -32,11 +33,19 @@ module.exports = function (jsonContent, {
mode,
srcMode,
env,
projectRoot
projectRoot,
useExtendComponents = {},
appInfo
} = mpx

const context = loaderContext.context

let hasApp = true

if (!appInfo.name) {
hasApp = false
}

const emitWarning = (msg) => {
loaderContext.emitWarning(
new Error('[Mpx json warning][' + loaderContext.resource + ']: ' + msg)
Expand Down Expand Up @@ -118,6 +127,16 @@ module.exports = function (jsonContent, {
if (ctorType !== 'app') {
rulesRunnerOptions.mainKey = ctorType
}
if (!hasApp || ctorType === 'app') {
if (useExtendComponents[mode]) {
const extendComponents = processExtendComponents({
useExtendComponents,
mode,
emitWarning
})
jsonObj.usingComponents = Object.assign({}, extendComponents, jsonObj.usingComponents)
}
}

const rulesRunner = getRulesRunner(rulesRunnerOptions)

Expand Down
1 change: 1 addition & 0 deletions packages/webpack-plugin/lib/react/processScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import { getComponent, getAsyncSuspense } from ${stringifyRequest(loaderContext,
output += buildI18n({ loaderContext })
}
output += getRequireScript({ ctorType, script, loaderContext })

output += `export default global.__mpxOptionsMap[${JSON.stringify(moduleId)}]\n`
}

Expand Down
1 change: 0 additions & 1 deletion packages/webpack-plugin/lib/react/script-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const parseRequest = require('../utils/parse-request')
const shallowStringify = require('../utils/shallow-stringify')
const normalize = require('../utils/normalize')
const addQuery = require('../utils/add-query')

function stringifyRequest (loaderContext, request) {
return loaderUtils.stringifyRequest(loaderContext, request)
}
Expand Down
Loading