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

组件class不能被解析 #129

Closed
lplsirlu opened this issue Dec 6, 2022 · 5 comments
Closed

组件class不能被解析 #129

lplsirlu opened this issue Dec 6, 2022 · 5 comments
Assignees
Labels
question Further information is requested

Comments

@lplsirlu
Copy link

lplsirlu commented Dec 6, 2022

image

image

这种组件的class好像不能正确被解析

@lplsirlu lplsirlu added the question Further information is requested label Dec 6, 2022
@sonofmagic
Copy link
Owner

这是因为我这个插件默认只转化 class hover-class 这一类的属性,
假如你想要自定义 prop 的转化,你可以这样做:
升级 weapp-tailwindcss-webpack-plugin1.12.6
然后给插件传递 options:

customAttributes: {
  '*': ['emptyImageClass']
}

详见 custom-attributes 配置项

@lplsirlu
Copy link
Author

lplsirlu commented Dec 7, 2022

image
"weapp-tailwindcss-webpack-plugin": "^1.12.6"
<MessageBar btnClassName=' bg-[#07C160]'></MessageBar>
image
还是不行,是其他也要升级嘛

@sonofmagic
Copy link
Owner

你这里又用了新的 prop 叫 btnClassName ,只配置 emptyImageClass 当然不起作用啦

你可以把新的prop添加进来比如这样配置:

customAttributes: {
  '*': ['emptyImageClass','btnClassName'],
}

或者嫌麻烦的话,后续还有很多自定义的prop的话,可以根据规律,使用正则:

customAttributes: {
   // 这个正则,同时匹配你上面的2中 prop 的名称
   '*': [/Class/]
}

@lplsirlu lplsirlu closed this as completed Dec 8, 2022
@lplsirlu
Copy link
Author

lplsirlu commented Dec 8, 2022

好的,感谢

@imaxing
Copy link

imaxing commented Aug 30, 2023

建议用大佬文档上的正则匹配
'*': [ /[A-Za-z]?[A-Za-z-]*[Cc]lass/ ],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants