Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 未找到模块:Can';t解决';样式化组件';_Javascript_Reactjs_Styled Components - Fatal编程技术网

Javascript 未找到模块:Can';t解决';样式化组件';

Javascript 未找到模块:Can';t解决';样式化组件';,javascript,reactjs,styled-components,Javascript,Reactjs,Styled Components,我使用create-react-app创建了一个新的react-app,然后使用npm安装了styled-component。但当我在组件中使用它时,我得到了以下错误 未能编译/src/Components/Lightbox/styledLightbox.js 未找到模块: 无法解析中的“样式化组件” “/Users/ishan/Documents/react-app/src/Components/Lightbox” 以下是组成部分: import React, { Component } fr

我使用
create-react-app
创建了一个新的react-app,然后使用
npm
安装了
styled-component
。但当我在组件中使用它时,我得到了以下错误

未能编译/src/Components/Lightbox/styledLightbox.js

未找到模块:

无法解析中的“样式化组件” “/Users/ishan/Documents/react-app/src/Components/Lightbox”

以下是组成部分:

import React, { Component } from 'react';
import { LightboxWrapper } from './styledLightbox';

class Lightbox extends Component {

    renderEntry() {
        if (this.props.lightbox.type === "photo") {
         return  <img alt="name" src={this.props.lightbox.entry} />;
        } 
        if (this.props.lightbox.type === "video") {
        return <video src={this.props.lightbox.entry} onLoadedMetadata={(e) => {console.log("Video duration is: "+e.currentTarget.duration) } } autoPlay muted onEnded={() => console.log("Video ended")} width='100%' height='100%' ></video> 
        }
        if(this.props.lightbox.type === "text"){
        return <div> <p className="lightbox text"> {this.props.lightbox.entry} </p> </div>   
        }

    }

    render() {
        let classList = this.props.lightbox.status === true ? "lightbox-wrapper active" : "lightbox-wrapper";
        return ( 
                <LightboxWrapper className={classList}>
                    {/* {this.renderEntry()} */}
                </LightboxWrapper>
         );
    }
}

export default Lightbox;
import styled from "styled-component";

export const LightboxWrapper = styled.div`
      display: none;
        position: fixed;
        z-index: 100;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        overflow: auto;
        background: radial-gradient(
                center, 
                ellipse farthest-corner, 
                rgba(255,255,255,0) 0%,
                rgba(255,255,255,0) 100%
        );
    .active {
        display: block;
        background: radial-gradient(
            center, 
            ellipse farthest-corner, 
            rgba(255,255,255,0.5) 0%,
            rgba(255,255,255,0.1) 100%
    );
    }
    .active img, .active video {
        max-width: 70%;
        height: auto !important;
        margin: 0 auto;
        opacity: 1;
        /* box-shadow: 0px 2px 7px rgba(0,0,0,0.2); */
        transition: opacity 0.5s linear;
        animation: fadeInScale 1.2s ease-in-out;
        max-height: 70%;
        width: auto !important;
        position: relative;
        top: 11%;
}
`;
您缺少“样式化组件”末尾的“s”


程序包名称是多元化的
样式化组件
。如果缺少“s”,请尝试从“样式化组件”导入样式化。。。还要检查您安装的依赖项的名称
$ npm i styled-components