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

cssModules 配置无效 #10037

Closed
hellozsh opened this issue Aug 12, 2021 · 3 comments
Closed

cssModules 配置无效 #10037

hellozsh opened this issue Aug 12, 2021 · 3 comments
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@hellozsh
Copy link

相关平台

微信小程序

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

复现步骤

1: 首先配置文件是true
cssModules: {
enable: true, // 默认为 false,如需使用 css modules 功能,则设为 true
config: {
namingPattern: 'module', // 转换模式,取值为 global/module
generateScopedName: '[name][local]_[hash:base64:5]'
}
}
2: 之后定义了一个Index.module.scss文件
.line_chart_bp {

width: 100%;
height: 100px;

background-color: yellow;
}
3: import styles from './Index.module.scss'
黄色背景

期望结果

有黄色背景

实际结果

无任何效果

环境信息

taro info
👽 Taro v3.3.1


  Taro CLI 3.3.1 environment info:
    System:
      OS: macOS 11.1
      Shell: 5.7.1 - /Users/zhousuhua/homebrew/bin/zsh
    Binaries:
      Node: 14.16.0 - ~/.nvm/versions/node/v14.16.0/bin/node
      Yarn: 1.22.10 - ~/.nvm/versions/node/v14.16.0/bin/yarn
      npm: 6.14.11 - ~/.nvm/versions/node/v14.16.0/bin/npm
    npmPackages:
      @tarojs/components: 3.3.1 => 3.3.1 
      @tarojs/mini-runner: 3.3.1 => 3.3.1 
      @tarojs/react: 3.3.1 => 3.3.1 
      @tarojs/runtime: 3.3.1 => 3.3.1 
      @tarojs/taro: 3.3.1 => 3.3.1 
      @tarojs/webpack-runner: 3.3.1 => 3.3.1 
      babel-preset-taro: 3.3.1 => 3.3.1 
      eslint-config-taro: 3.3.1 => 3.3.1 
      react: ^17.0.0 => 17.0.2 
      taro-ui: 3.0.0-alpha.10 => 3.0.0-alpha.10 
    npmGlobalPackages:
      typescript: 4.3.5
@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Aug 12, 2021
@hellozsh
Copy link
Author

hellozsh commented Aug 12, 2021

<View className={styles.line_chart_bp}>黄色背景</View>

@hellozsh
Copy link
Author

已经解决了,我是因为一个文件里又使用了字符串,又使用了style,都改成style就好了

@zhongjiaguo001
Copy link

已经解决了,我是因为一个文件里又用了字符串,又用了风格,都改成风格就好了
老哥,我也出现了这样的问题,但是我是新创建的项目,只有一个地方用到了className,但是他没有生效

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests

2 participants