我已经在我的项目中添加了React Awesomeslider,该项目由Gatsby.js,Next.js以及Sanity.io作为CMS构建。当前,css由post css配置。
https://github.com/rcaferati/react-awesome-slider
我已经按照文档中的建议链接了普通的CSS(并且我没有为此项目使用scss)。
这是我的组成部分
import PropTypes from "prop-types";
import styles from "./Hero.module.css";
import client from "../../client";
import SimpleBlockContent from "../SimpleBlockContent";
import Cta from "../Cta";
import imageUrlBuilder from "@sanity/image-url";
import AutoplaySlider from "react-awesome-slider";
import AwesomeSliderStyles from "react-awesome-slider/dist/styles.css";
const builder = imageUrlBuilder(client);
function Hero(props) {
const { heading, image, tagline, ctas } = props;
const images = props.image;
return (
<div className={styles.root}>
<div className={styles.content}>
<h1 className={styles.title}>{heading}</h1>
<div className={styles.tagline}>{tagline && <SimpleBlockContent blocks={tagline} />}</div>
<AutoplaySlider
play={true}
cancelOnInteraction={false}
interval={6000}
style={AwesomeSliderStyles}
>
<div>
{images.map((image) => (
<img
className={styles.image}
src={builder.image(image).url()}
className={styles.image}
alt={heading}
/>
))}
</div>
</AutoplaySlider>
</div>
</div>
);
}
Hero.propTypes = {
heading: PropTypes.string,
backgroundImage: PropTypes.object,
tagline: PropTypes.array,
ctas: PropTypes.arrayOf(PropTypes.object),
};
export default Hero;
所有内容均显示为已导入,并且滑块显示在页面上,但是我在控制台中显示了该内容...
Warning: Unsupported style property awssld__timer--hidden. Did you mean awssld__timer-hidden?
其他css似乎都没有通过。有人遇到过吗?
任何帮助将不胜感激。
谢谢
答案 0 :(得分:0)
要使用外部CSS文件,您需要在CSS文件路径的末尾添加?raw
,如下所示:
import AwesomeSliderStyles from "react-awesome-slider/dist/styles.css?raw";
在此处记录?https://www.sanity.io/docs/styling#using-external-css-in-sanity-22b29fe9dcd4