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

按官网方式全局注入 scss 后,并不能使用用全局的scss变量 #7993

Open
mingtianyihou33 opened this issue Nov 6, 2020 · 1 comment
Assignees
Labels
F-vue2 Framework - Vue 2 T-h5 Target - 编译到 H5 V-3 Version - 3.x

Comments

@mingtianyihou33
Copy link

相关平台

H5

浏览器版本: Google Chrome 86.0.4240.183
使用框架: Vue 2

复现步骤

1.创建scss变量管理文件
src/assets/style/variable.scss
2.在文件中写入
$color-body-bg: #F6F6F6;
3.在config/index.js添加配置
config: {
...
sass: {
resource: path.resolve(__dirname, '..', 'src/assets/style/variable.scss'),
},
...
}
4.启动项目
5.在src/app.scss中使用scss变量
.layout-main {
background-color: $color-msg-bg;
}
6.控制台将会报错
SassError: Undefined variable.

4 │ background-color: $color-body-bg;
│ ^^^^^^^^^^^^^

期望结果

正常使用全局scss变量

实际结果

编译报错

环境信息

Taro CLI 3.0.16 environment info:
    System:
      OS: macOS 10.15.7
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 14.4.0 - /usr/local/bin/node
      Yarn: 1.22.10 - /usr/local/bin/yarn
      npm: 6.14.7 - /usr/local/bin/npm
    npmPackages:
      @tarojs/cli: 3.0.16 => 3.0.16 
      @tarojs/components: 3.0.16 => 3.0.16 
      @tarojs/mini-runner: 3.0.16 => 3.0.16 
      @tarojs/runtime: 3.0.16 => 3.0.16 
      @tarojs/taro: 3.0.16 => 3.0.16 
      @tarojs/webpack-runner: 3.0.16 => 3.0.16 
      babel-preset-taro: 3.0.16 => 3.0.16 
      eslint-config-taro: 3.0.16 => 3.0.16 

@taro-bot2 taro-bot2 bot added F-vue2 Framework - Vue 2 T-h5 Target - 编译到 H5 V-3 Version - 3.x labels Nov 6, 2020
@ZakaryCode ZakaryCode moved this to 框架 in H5 Apr 10, 2023
@ZakaryCode ZakaryCode added this to H5 Apr 10, 2023
@AprilNEA
Copy link

该问题是否有解决方案?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-vue2 Framework - Vue 2 T-h5 Target - 编译到 H5 V-3 Version - 3.x
Projects
Status: 框架
Development

No branches or pull requests

3 participants