我正在开发一个使用node-sass编译SCSS的应用程序。我的组件结构是这样的:
./src
|-- components
| |-- Foo
| | |-- Foo.jsx
| | `-- Foo.scss
| |-- Bar
| |-- Bar.jsx
| `-- Bar.scss
[...]
然后我就这样叫我的scss:
import React, {useState} from 'react';
import './Foo.scss';
[...]
当我运行开发版本时,我所有的过渡都可以,但是当我运行构建和部署时,它们会丢失。所有其他CSS样式都可以正常工作,只是我的转换搞砸了。它们仍然存在,但是它们都发生在最后一帧。因此,如果应该在200ms内从0到100过渡,它仍然会发生,但在最后一个可能的帧中会从0到100。
有人能指出我正确的方向吗?这是我的package.json:
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"node-sass": "^4.14.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-icons": "^3.10.0",
"react-map-gl": "^5.2.7",
"react-map-gl-geocoder": "^2.0.12",
"react-redux": "^7.2.0",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "^3.4.3",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
编辑:根据要求,以下是我的转换示例:
.fade-in {
animation: fade-in ease-in 0.25s,
slide-in ease-in 0.25s;
}
@keyframes fade-in {
0% {
opacity: 0%;
}
100% {
opacity: 100%;
}
}
@keyframes slide-in {
0%{
transform: translateY(50px);
}
100%{
transform: translateY(0px);
}
}
然后我根据状态有条件地添加类。