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

#ifdef 的条件编译不生效,在taro 4.0.8版本 #17220

Open
a709691139 opened this issue Jan 24, 2025 · 0 comments
Open

#ifdef 的条件编译不生效,在taro 4.0.8版本 #17220

a709691139 opened this issue Jan 24, 2025 · 0 comments

Comments

@a709691139
Copy link
Contributor

a709691139 commented Jan 24, 2025

相关平台

H5

复现仓库

https://gitee.com/zhengjinpeng/temp_taro.git
浏览器版本: Microsoft Edge 版本 132.0.2957.115 (正式版本) (64 位)
使用框架: React

复现步骤

taro init 项目,选择 react-native 。
然后修改首页内容添加条件编译的console.log

 componentDidMount() {
    /*  #ifdef rn  */
    console.log("rn");
    /*  #endif  */
    
    /*  #ifdef h5  */
    console.log("h5");
    /*  #endif  */
  }

运行yarn dev:h5 , 发现 rn 和h5两行代码都执行了

期望结果

只执行#ifdef对应环境的代码

实际结果

全部环境都执行了,没有区分开

环境信息

 Taro v4.0.8


  Taro CLI 4.0.8 environment info:
    System:
      OS: Windows 11 10.0.22631
    Binaries:
      Node: 18.16.0 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
      npm: 9.5.1 - C:\Program Files\nodejs\npm.CMD
    npmPackages:
      @tarojs/cli: 4.0.8 => 4.0.8
      @tarojs/components: 4.0.8 => 4.0.8
      @tarojs/components-rn: 4.0.8 => 4.0.8
      @tarojs/helper: 4.0.8 => 4.0.8
      @tarojs/plugin-framework-react: 4.0.8 => 4.0.8
      @tarojs/plugin-platform-alipay: 4.0.8 => 4.0.8
      @tarojs/plugin-platform-h5: 4.0.8 => 4.0.8
      @tarojs/plugin-platform-jd: 4.0.8 => 4.0.8
      @tarojs/plugin-platform-qq: 4.0.8 => 4.0.8
      @tarojs/plugin-platform-swan: 4.0.8 => 4.0.8
      @tarojs/plugin-platform-tt: 4.0.8 => 4.0.8
      @tarojs/plugin-platform-weapp: 4.0.8 => 4.0.8
      @tarojs/react: 4.0.8 => 4.0.8
      @tarojs/rn-runner: 4.0.8 => 4.0.8
      @tarojs/rn-supporter: 4.0.8 => 4.0.8
      @tarojs/runtime: 4.0.8 => 4.0.8
      @tarojs/runtime-rn: 4.0.8 => 4.0.8
      @tarojs/shared: 4.0.8 => 4.0.8
      @tarojs/taro: 4.0.8 => 4.0.8
      @tarojs/taro-loader: 4.0.8 => 4.0.8
      @tarojs/taro-rn: 4.0.8 => 4.0.8
      @tarojs/webpack5-runner: 4.0.8 => 4.0.8
      babel-preset-taro: 4.0.8 => 4.0.8
      eslint-config-taro: 4.0.8 => 4.0.8
      react: ^18.2.0 => 18.3.1
      react-native: ^0.73.1 => 0.73.11

This was referenced Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant