我把一个项目从魅力转移到情感。唯一丢失的拼图?测试。
在Glamorous中,我可以找到这样的选择元素:
$component.find('StyledComponent');
$component.find('StyledComponent[prop="value"]');
这不再管用了。到目前为止,我发现最好的方法是:
import StyledComponent from 'my/ui/StyledComponent';
$component.find(StyledComponent);
$component.find(StyledComponent).filter('[prop="value"]');
我喜欢前面的方法,因为根本不需要导入组件。有些情感成分在文件中定义而不导出它们。在这些情况下,会更加冗长:
$component.find('div[className*="StyledComponent"]');
$component.find('div[className*="StyledComponent"][prop="value"]'); // or
$component.find('div[className*="StyledComponent"]').filter('[prop="value"]')
有更好的办法吗?谢谢你的阅读!