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

请教如何配置customAttributes? #3

Open
deajax opened this issue Aug 7, 2023 · 1 comment
Open

请教如何配置customAttributes? #3

deajax opened this issue Aug 7, 2023 · 1 comment
Assignees

Comments

@deajax
Copy link

deajax commented Aug 7, 2023

我是直接下载的这个模版项目,但是因为t-design里的t-class无法识别!的通配符,看到issue#129,issue#134的解释,想增加配置项customAttributes到config里,但是不知道应该加到哪里,可以请给个示例吗?

@sonofmagic sonofmagic self-assigned this Aug 7, 2023
@sonofmagic
Copy link
Member

比如 https://tdesign.tencent.com/miniprogram/components/button?tab=api#button-%E5%A4%96%E9%83%A8%E6%A0%B7%E5%BC%8F%E7%B1%BB

这个 t-button 有三个外部样式类 ['t-class', 't-class-icon', 't-class-loading'],你就可以这样配置:
来到 webpack.config.js 找到 UnifiedWebpackPluginV5:

    new UnifiedWebpackPluginV5({
      customAttributes: {
       // 只对 t-button 标签生效
        't-button': ['t-class', 't-class-icon', 't-class-loading'],
       //'*' 代表对所有的标签生效
       //'*': ['t-class', 't-class-icon', 't-class-loading'],
      },
    }),

同理,其他的组件的外部样式类,也可以这样配置。

当然,如果你能总结出转换属性名称的规律的话,数组里面也是允许传入正则表达式的。

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

2 participants