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

tarocli 开启 css module 的 bug #1388

Closed
DiamondYuan opened this issue Dec 5, 2018 · 4 comments · Fixed by #2712
Closed

tarocli 开启 css module 的 bug #1388

DiamondYuan opened this issue Dec 5, 2018 · 4 comments · Fixed by #2712
Assignees

Comments

@DiamondYuan
Copy link
Contributor

DiamondYuan commented Dec 5, 2018

"@tarojs/cli": "1.2.0-beta.4"

复现方法
首先有两个文件

index.tsx

import styles from './login.scss';

<Button onClick={this.handleLogin} className={styles.loginBtn}>

index.scss

.loginBtn {
  background: #ddd;
  width: 50vw;
  border: none;
  border-radius: 80px;
  color: #fff;
  padding: 10px 20px;
  font-size: 28px;
}

第一步

index.tsx 修改样式名称

import styles from './login.scss';

<Button onClick={this.handleLogin} className={styles.loginBtn2}>

第二步

index.scss 修改样式名称

.loginBtn2 {
 background: #ddd;
 width: 50vw;
 border: none;
 border-radius: 80px;
 color: #fff;
 padding: 10px 20px;
 font-size: 28px;
}

第三步

此时我们发现无论如何修改 .loginBtn2 中的内容都不会生效。直到我们重新保存一下 index.tsx
因为第一步结果生成的 wxml 中的 loginBtn 都不会改变了,永远是空

 <button bindtap="handleLogin" class="{{styles.loginBtn}}">登陆</button>

解决方案 修改 index.scss 的时候应该吧 index.tsx 也重新生成一下,无论代码有没有变。

@taro-bot
Copy link

taro-bot bot commented Dec 5, 2018

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@taro-bot
Copy link

taro-bot bot commented Dec 5, 2018

CC @luckyadam

@Miantang
Copy link

这个问题目前有进展吗。

@yesmeck
Copy link
Contributor

yesmeck commented Apr 9, 2019

现在应该是不知道 css 文件被哪个 js 文件依赖了,所以没办法去更新 js 文件吧?能不能把类名抽到一个独立的 js 文件里,然后在需要的组件里 require。这样 css 更新的时候只要去更新抽出来的那个文件就可以了。

yesmeck added a commit to yesmeck/taro that referenced this issue Apr 9, 2019
yesmeck added a commit to yesmeck/taro that referenced this issue Apr 9, 2019
yesmeck added a commit to yesmeck/taro that referenced this issue Apr 9, 2019
yesmeck added a commit to yesmeck/taro that referenced this issue Apr 11, 2019
luckyadam pushed a commit that referenced this issue Apr 18, 2019
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

Successfully merging a pull request may close this issue.

4 participants