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

h5 Swiper组件报错 undefined is not an object (evaluating 'h.$wrapperEl.transition') #11767

Closed
bluescurry opened this issue May 6, 2022 · 3 comments
Labels
F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x

Comments

@bluescurry
Copy link
Contributor

相关平台

微信小程序

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

复现步骤

组件代码是这样的,线上一直有报警,报警信息就是undefined is not an object (evaluating 'h.$wrapperEl.transition'),但是一直没复现出来,定位代码的位置是 node_modules/@tarojs/components/dist/esm-es5/taro-swiper-core_2.entry.js 这个文件,不知道是我用法不对,还是源码哪块没有兼容,麻烦大佬给看下

const Banner = ({ list }) => {
  const [activeDot, setActiveDot] = useState(0);

  useEffect(() => {
    setActiveDot(0);
  }, [list]);

  return (
    <View className={styles.container}>
      {list.length === 1 && (
        <View className={styles.swiper}>
          <Image className={styles.swiperImage} src={list[0].imgUrl}></Image>
        </View>
      )}
      {/* banner 轮播 */}
      {list.length > 1 && (
        <Fragment>
          <Swiper
            className={styles.swiper}
            circular
            autoplay
            current={activeDot}
            onChange={({ detail }) => {
              setActiveDot(detail.current);
            }}
          >
            {list.map((banner) => (
              <SwiperItem key={banner.imgUrl}>
                <Image
                  src={banner.imgUrl}
                ></Image>
              </SwiperItem>
            ))}
          </Swiper>
          {/* 轮播图指示器 */}
          <View className={styles.indicatorDot}>
            {list.map((banner, index) => (
              <View
                key={banner.imgUrl}
              />
            ))}
          </View>
        </Fragment>
      )}
    </View>
  );
};

期望结果

不报错

实际结果

报错导致页面白屏

环境信息

👽 Taro v3.4.8


  Taro CLI 3.4.8 environment info:
    System:
      OS: macOS 12.3.1
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 16.13.0 - /usr/local/bin/node
      Yarn: 1.22.17 - /usr/local/bin/yarn
      npm: 8.1.1 - /usr/local/bin/npm
    npmPackages:
      @tarojs/cli: ^3.4.8 => 3.4.8
      @tarojs/components: ^3.4.8 => 3.4.8
      @tarojs/mini-runner: ^3.4.8 => 3.4.8
      @tarojs/plugin-framework-react: ^3.4.8 => 3.4.8
      @tarojs/react: ^3.4.8 => 3.4.8
      @tarojs/runtime: ^3.4.8 => 3.4.8
      @tarojs/taro: ^3.4.8 => 3.4.8
      @tarojs/webpack-runner: ^3.4.8 => 3.4.8
      babel-preset-taro: ^3.4.8 => 3.4.8
      eslint-config-taro: ^3.4.8 => 3.4.8
      react: ^17.0.1 => 17.0.2

补充信息

UA:
Mozilla/5.0 (iPhone; CPU iPhone OS 15_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.16(0x18001023) NetType/WIFI Language/zh_CN miniProgram

浏览器:micromessenger 8.0.16
JS引擎:webkit 605.1.15
操作系统:ios15.4.1
设备:iphone

@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels May 6, 2022
@ZakaryCode ZakaryCode added T-h5 Target - 编译到 H5 and removed T-weapp Target - 编译到微信小程序 labels May 9, 2022
@ZakaryCode
Copy link
Contributor

给个可以验证的环境看看咯

@shoestrong
Copy link

我也遇到了此问题

@uaenali
Copy link

uaenali commented Sep 13, 2023

有解决办法了吗

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

4 participants