开发组件时所有style都会出现两次

发布于 8 年前作者 minghu1509 次浏览最后编辑 8 年前来自 ask

声明:这个问题用稳定版和beta版开发工具都可以稳定重现。

我在开发组件的时候,如果添加了

Component({
options: {
/** todo: this will cause all style classes appear twice */
   addGlobalClass: true
 }
})

我调试编译后的结果会发现每个style class 都出现了2次。

3 回复
xiongxiuying
xiongxiuying1 楼6 年前

options 配置文件addGlobalClass和styleIsolation都会导致这问题,这两个配置都用默认值就可以了;

如果组件样式中需要app.sxss公用样式,可以在组件样式文件中使用 @import “/app.wxss”;导入全局样式

iding
iding2 楼6 年前

你好,请提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

huwei
huwei3 楼6 年前

我也遇到的同样的问题。设置addGlobalClass为true时,页面渲染的dom结构上的class重复