简体   繁体   English

请求的模块“./react.js”不提供名为“默认”的导出

[英]The requested module './react.js' does not provide an export named 'default'

I am learning React but i am stuck here since a week, can't figure it out,!我正在学习 React,但我被困在这里一周以来,无法弄清楚,! please help I am learning React but i am stuck here since a week , can't figure it out !!请帮助我正在学习 React,但我被困在这里一周以来,无法弄清楚! please help请帮忙

index.html:索引.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

    <!-- Load our React component. -->


</head>
<body>
   <div id="apps">

   </div> 
   <script type="module" src="./script.js"></script>  
</body>
</html>

Navbar.js:导航栏.js:

import React from './react.js';
//import {ReactDOM} from './react-dom.js';
export class NavBar extends Component {
    constructor(props) {
        super(props);
        this.state = {  }
    }
    render() { 
    return ( this.props.items.map(item =>{ <li>{item}</li>}));
    }
}


script.js脚本.js

//import {React} from './react.js';
//import {ReactDOM} from './react-dom.js';
import   {NavBar}  from './navbar.js';
ReactDOM.render(
  <NavBar items={['Rohit','Rajiv']}/>,
  document.getElementById('root')
);

I am getting this error The requested module './react.js' does not provide an export named 'default'我收到此错误The requested module './react.js' does not provide an export named 'default'

Try import * as React from 'react';尝试import * as React from 'react';

To begin with, in your provided source code there are several issues that stand out.首先,在您提供的源代码中,有几个问题很突出。

To take advantage of the answers provided to you here it will require some understanding of how react works, such as setting up a basic react project, and some familiarity with the react eco-system, such as node, npm and babel.要利用此处提供给您的答案,您需要了解 react 的工作原理,例如设置基本的 react 项目,并熟悉 react 生态系统,例如 node、npm 和 babel。 Not to mention a sufficient understanding of JavaScript and the ES6 syntax.更不用说对 JavaScript 和 ES6 语法有足够的了解了。

There are many getting started guides for react available online that can get you up and running in a short amount of time.有许多在线可用的 react 入门指南,可以让您在短时间内启动并运行。

I recommend ignoring your current progress for now and start with this guide.我建议暂时忽略您当前的进度并从本指南开始。

w3Schools.com React Tutorial w3Schools.com React 教程

Follow all the steps in this tutorial.按照本教程中的所有步骤进行操作。 It is explained step by step, and by the end of it you will have solid understanding of using react.它是一步一步解释的,到最后你将对使用 react 有一个深刻的理解。 Take your time, and finish this tutorial from start to finish.花点时间,从头到尾完成本教程。 That is my advice, as finishing one tutorial from start to finish is better than starting 50 and not finishing them.这是我的建议,因为从头到尾完成一个教程比开始 50 个教程而不完成它们要好。

If you would like, leave a comment and you can get in touch with me via email with any difficulties and Ill do my best to help out.如果您愿意,请发表评论,如有任何困难,您可以通过 email 与我联系,我会尽力提供帮助。

Best of luck and hope you have fun along the way.祝您好运,并希望您在此过程中玩得开心。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 请求的模块不通过快速路由提供名为 default 的导出 - The requested module does not provide an export named default via express routing SyntaxError:请求的模块“sqlite”不提供名为“default”的导出 - SyntaxError: The requested module 'sqlite' does not provide an export named 'default' 未捕获的语法错误:请求的模块“/@modules/vue.js”未提供名为“默认”的导出 - Uncaught SyntaxError: The requested module '/@modules/vue.js' does not provide an export named 'default' 请求的模块“./server/controller/controller.js”不提供名为“default”的导出 - The requested module './server/controller/controller.js' does not provide an export named 'default' “请求的模块 &#39;./login.js&#39; 不提供名为 &#39;loggedIn&#39; 的导出 - "The requested module './login.js' does not provide an export named 'loggedIn' 请求的模块不提供名为的导出 - The requested module does not provide an export named 未捕获的语法错误:请求的模块“https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js”未提供名为“default”的导出 - Uncaught SyntaxError: The requested module 'https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js' does not provide an export named 'default' 导入/导出错误:请求的模块未提供名为“pageFlip”的导出 - Import/Export error: The requested module does not provide an export named 'pageFlip' 如何修复“请求的模块不提供名为‘默认’的导出”? - How do I fix "the requested module does not provide an export named 'default'"? 使用 importmap 使用 jquery 会出现错误“请求的模块 'jquery' 不提供名为 'default' 的导出” - Consuming jquery using importmap gives error "The requested module 'jquery' does not provide an export named 'default'"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM