Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taro3.6.2 虚拟列表在支付宝小程序中报错 #13442

Closed
HyaCiovo opened this issue Mar 13, 2023 · 1 comment
Closed

Taro3.6.2 虚拟列表在支付宝小程序中报错 #13442

HyaCiovo opened this issue Mar 13, 2023 · 1 comment
Labels
A-components-advanced Area - 高阶组件 F-react Framework - React T-alipay Target - 编译到支付宝小程序 V-3 Version - 3.x

Comments

@HyaCiovo
Copy link

HyaCiovo commented Mar 13, 2023

相关平台

支付宝小程序

小程序基础库: 2.8.3
使用框架: React

复现步骤

import React from "react";
import { View } from "@tarojs/components";
import Taro from "@tarojs/taro";
import VirtualList from "@tarojs/components/virtual-list"
import styles from "./styles.module.less"

const Introduction: React.FC = () => {
  Taro.hideShareMenu();
  const buildData = (offset:number = 0) => {
    return Array(100).fill(0).map((_, i) => i   offset);
  }
  const data = buildData(0)
  const Row = React.memo(({ id, index, style, _data }: any) => {
    return (
      <View id={id} className={index % 2 ? 'ListItemOdd' : 'ListItemEven'} style={style}>
        Row {index}
      </View>
    );
  })
  return (
    <View className={styles.page}>
      平台介绍
      <VirtualList
        height={500} // 列表的高度
        width="100%" // 列表的宽度
        item={Row} // 列表单项组件,这里只能传入一个组件
        itemData={data} // 渲染列表的数据
        itemCount={data.length} // 渲染列表的长度
        itemSize={100} // 列表单项的高度
      />
    </View>
  );
};

export default Introduction;

使用上述代码在微信小程序的开发者工具上打开可以正常显示,但在支付宝小程序中打开报错。

微信中:
01bc2dc4ecded666df1925e3e092486

支付宝中:
31b178c87f8df9bc4cc5aa74c494429

期望结果

VirtualList虚拟列表组件可以在支付宝小程序中正常使用

实际结果

引入后报错:
taro.js:2304 Uncaught TypeError: Cannot set property default of # which has only a getter
at Object.node_modulesTarojsComponentsVirtualListIndexJs (VM348 index.worker.js:53540:31)
at webpack_require (VM348 index.worker.js:29620:47)
at Object.node_modulesBabelLoaderLibIndexJsRuleSet1Rules5Use0SrcPagesPackageAIntroductionIndexTsx (VM152 index.worker.js:13397:96)
at webpack_require (VM348 index.worker.js:29620:47)
at Object.srcPagesPackageAIntroductionIndexTsx (VM152 index.worker.js:13466:138)
at webpack_require (VM348 index.worker.js:29620:47)
at webpack_exec (VM152 index.worker.js:14182:16)
at eval (VM152 index.worker.js:14185:16)
at Function.DP7x.webpack_require.O (VM348 index.worker.js:29664:37)
at eval (VM152 index.worker.js:14187:59)

环境信息

  Taro CLI 3.6.2 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 16.15.1 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.22.19 - C:\Program Files\nodejs\node_global\yarn.CMD
      npm: 8.11.0 - C:\Program Files\nodejs\npm.CMD

补充信息

测试该组件在微信小程序中是可以正常使用的

@taro-bot2 taro-bot2 bot added F-react Framework - React T-alipay Target - 编译到支付宝小程序 V-3 Version - 3.x labels Mar 13, 2023
@ZakaryCode ZakaryCode added the A-components-advanced Area - 高阶组件 label Mar 21, 2023
@ZakaryCode
Copy link
Contributor

看报错和 #13360 是一个问题,在新版本中也没有复现到,可以先等 3.6.3 验证下

TheKonka added a commit to TheKonka/taro that referenced this issue Apr 20, 2023
@TheKonka TheKonka mentioned this issue Apr 20, 2023
18 tasks
ZakaryCode added a commit that referenced this issue Apr 20, 2023
* fix: virtual-list export

#13360 #13442

* Update index.js

* Update index.js

---------

Co-authored-by: Flame <wshx1938@163.com>
Co-authored-by: Zakary <zakarycode@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-components-advanced Area - 高阶组件 F-react Framework - React T-alipay Target - 编译到支付宝小程序 V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests

2 participants