【发布时间】:2021-11-06 20:44:09
【问题描述】:
以下行出现错误 Unknown word CssSyntaxError:
动画:${props => (css${DeterminateFill(props)} 1s ease-in forwards)};
它在以下样式组件中
const DeterminateLinearProgressDiv = styled(ProgressDiv)`
animation: ${props => (css`${DeterminateFill(props)} 1s ease-in forwards`)};
`
DeterminateFill 如下:
const DeterminateFill = (props) => {
const valuePercent = `${props.value}%`
const startPercent = `${props.start}%`
return keyframes`
0% {left: 0%; width: ${startPercent};}
100% {left: 0%; width: ${valuePercent};}
`
}
代码运行良好,符合我的预期,今天开始使用 stylelint。
"stylelint": "^13.13.1",
"stylelint-config-recommended": "^5.0.0",
"stylelint-config-styled-components": "^0.1.1",
"stylelint-processor-styled-components": "^1.10.0",
并将 stylelint.config.js 设置为
module.exports = {
processors: ['stylelint-processor-styled-components'],
extends: [
'stylelint-config-recommended',
'stylelint-config-styled-components',
]
}
【问题讨论】: