反应将不会导入我的模块“模块找不到:无法解析”

问题描述 投票:-1回答:2

反应不解决我的组件导入到我的YouTubeApp.js。这似乎傻了,我还有其他的成分在我的反应的应用程序,我能没有问题,但是这一次我特别不能把它导入到导入。

Github上:https://github.com/JAlonsoHdz/React_UnsplashClientApp/tree/master/src/components

其他方面,YouTubeApp.js目前进口在我index.js没有问题。我使用的是反应在index.js和链接和路线链接成功地导入到YouTubeApp.js路由。出现这个问题whenver我尝试导入任何部件到YouTubeApp.js我得到的无法解析“组件名称”错误,没有任何进口YouTubeApp.js正常工作的组成部分。

我已经验证了正确的路径,该组件的名称。

YouTube的App.js

import React from 'react';
import Other from './components/other';


class YouTubeApp extends React.Component {
    render() {
        return (<p>test</p>

        );
    }
}

export default YouTubeApp;

这是我的组件我试图导入:

import React from 'react';

class Other extends React.Component {
    render() {
        return (
            <div clasNames="ui container">test!</div>           
            );
    }
}

export default Other;

我需要嵌套至少有几个水平下降更多的组件,但这个问题阻止。

reactjs
2个回答
0
投票

看着你的GitHub库,看来YouTubeApp.js和other.js都在“组件”目录。因此,当在YouTubeApp.js(或在您的“组件”目录中的任何其他组件)的进口应该是:

import Other from './other';

-1
投票

你可能只是需要将扩展​​添加到其他。

尝试:导入其他从” ./components/other.js';

© www.soinside.com 2019 - 2024. All rights reserved.