原始问题:
`${props.type}-color` 这样获取css中的变量样式怎么获取
可以使用CSS Custom Properties(CSS自定义属性)来获取css中的变量样式。例如`css
:root {
--primary-color: #00f;
}
你可以在javascript中使用window.getComputedStyle()方法来获得这个值: let primaryColor = window.getComputedStyle(document.documentElement).getPropertyValue('--primary-color'); // #00f `
Prev:寻找一个智能投顾的案例