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

使用VirtualList 组件 滚动时报createSelectorQuery方法不存在的错误 #11622

Closed
lxsunbin opened this issue Apr 12, 2022 · 5 comments
Closed
Labels
F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x

Comments

@lxsunbin
Copy link

lxsunbin commented Apr 12, 2022

相关平台

H5

浏览器版本: Chrome 99
使用框架: React

复现步骤

按照官网示例使用VirtualList组件, 渲染后滚动内容,就会报错_tarojs_taro__WEBPACK_IMPORTED_MODULE_0__.default.createSelectorQuery is not a function

import React, { Component } from 'react'
import { View} from '@tarojs/components'
import VirtualList from '@tarojs/components/virtual-list'
import './index.scss'
function buildData (offset = 0) {
  return Array(100).fill(0).map((_, i) => i + offset);
}

const Row = React.memo(({ id, index, style, data }) => {
  return (
    <View id={id} className={index % 2 ? 'ListItemOdd' : 'ListItemEven'} style={style}>
      Row {index} : {data[index]}
    </View>
  );
})

export default class Index extends Component {
  state = {
    data: buildData(0),
  }

  render() {
    const { data } = this.state
    const dataLen = data.length
    return (
      <VirtualList
        height={500} /* 列表的高度 */
        width='100%' /* 列表的宽度 */
        itemData={data} /* 渲染列表�的数据 */
        itemCount={dataLen} /*  渲染列表的长度 */
        itemSize={100} /* 列表单项的高度  */
      >
        {Row}
      </VirtualList>
    );
  }
}

期望结果

滚动页面正常

实际结果

滚动页面报错
createListComponent.js?587f:25 Uncaught (in promise) TypeError: tarojs_taro__WEBPACK_IMPORTED_MODULE_0_.default.createSelectorQuery is not a function

环境信息


  Taro CLI 3.4.1 environment info:
    System:
      OS: macOS 10.15.7
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 10.18.0 - /usr/local/bin/node
      Yarn: 1.22.4 - /usr/local/bin/yarn
      npm: 6.13.4 - /usr/local/bin/npm
    npmPackages:
      @tarojs/cli: ^3.4.2 => 3.4.2 
      @tarojs/components: 3.4.0 => 3.4.0 
      @tarojs/mini-runner: 3.4.0 => 3.4.0 
      @tarojs/react: 3.4.0 => 3.4.0 
      @tarojs/runtime: 3.4.0 => 3.4.0 
      @tarojs/taro: 3.4.0 => 3.4.0 
      @tarojs/webpack-runner: 3.4.0 => 3.4.0 
      babel-preset-taro: 3.4.0 => 3.4.0 
      eslint-config-taro: 3.4.0 => 3.4.0 
      react: ^17.0.0 => 17.0.2 

补充信息

搜索以前有人提过一样的issue,看上去之前解决了,但是现在还有这样的问题,求解

@taro-bot2 taro-bot2 bot added F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x labels Apr 12, 2022
@ZakaryCode
Copy link
Contributor

升级到最新版本修复该问题

@lxsunbin
Copy link
Author

升级到最新版本修复该问题

请问下我当前版本是3.4.0,如果升级到最新版本,是否需要注意一下兼容的问题

@ZakaryCode
Copy link
Contributor

请问下我当前版本是3.4.0,如果升级到最新版本,是否需要注意一下兼容的问题

小版本一般不会有太大差异,具体可以关注版本说明

@lxsunbin
Copy link
Author

请问下我当前版本是3.4.0,如果升级到最新版本,是否需要注意一下兼容的问题

小版本一般不会有太大差异,具体可以关注版本说明

好的谢谢,已升级到3.4.6版本,问题解决。

但我没在3.4.0-3.4.6这个几个版本说明里看到关于这个问题的修复。。。

@TestSmirk
Copy link

👽 Taro v3.6.3


  Taro CLI 3.6.3 environment info:
    System:
      OS: macOS 13.2.1
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 18.14.2 - /usr/local/bin/node
      Yarn: 1.22.19 - /usr/local/bin/yarn
      npm: 9.5.0 - /usr/local/bin/npm
    npmPackages:
      @tarojs/cli: 3.6.3 => 3.6.3 
      @tarojs/components: 3.6.3 => 3.6.3 
      @tarojs/helper: 3.6.3 => 3.6.3 
      @tarojs/plugin-framework-react: 3.6.3 => 3.6.3 
      @tarojs/plugin-html: 3.6.3 => 3.6.3 
      @tarojs/plugin-platform-alipay: 3.6.3 => 3.6.3 
      @tarojs/plugin-platform-jd: 3.6.3 => 3.6.3 
      @tarojs/plugin-platform-qq: 3.6.3 => 3.6.3 
      @tarojs/plugin-platform-swan: 3.6.3 => 3.6.3 
      @tarojs/plugin-platform-tt: 3.6.3 => 3.6.3 
      @tarojs/plugin-platform-weapp: 3.6.3 => 3.6.3 
      @tarojs/react: 3.6.3 => 3.6.3 
      @tarojs/router: 3.6.3 => 3.6.3 
      @tarojs/runtime: 3.6.3 => 3.6.3 
      @tarojs/shared: 3.6.3 => 3.6.3 
      @tarojs/taro: 3.6.3 => 3.6.3 
      @tarojs/taro-h5: 3.6.3 => 3.6.3 
      @tarojs/webpack5-runner: 3.6.3 => 3.6.3 
      babel-preset-taro: 3.6.3 => 3.6.3 
      eslint-config-taro: 3.6.3 => 3.6.3 
      react: ^18.0.0 => 18.2.0 
    npmGlobalPackages:
      typescript: 5.0.2

3.6.3 问题又出现了.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x
Projects
Archived in project
Development

No branches or pull requests

3 participants