精华内容
下载资源
问答
  • react.development.js

    2021-03-10 13:22:37
    react.development.js
  • 包括react.development.js;babel.min.js;react-dom.development.js三个js文件
  • React.js所需的三个js文件之1--react.development.v17.js,在head引入script即可使用。
  • 今天写新需求的时候,老js文件中动辄几千行,前人把好多东西都揉在一起。想着新功能就写在新的js文件中好了。 于是引用了新的js文件,可是报出了如下错误 二、问题原因分析 隐约知道应该是引入方面或者是...

    目录

     

    一、问题描述

    二、问题原因分析

    三、问题解决

    四、总结


    一、问题描述

    今天写新需求的时候,老js文件中动辄几千行,前人把好多东西都揉在一起。想着新功能就写在新的js文件中好了。

    于是引用了新的js文件,可是报出了如下错误

     

     

     

     

    二、问题原因分析

    隐约知道应该是引入方面或者是导出方面的问题,但是也没有准确定位到在哪里有问题

    最后在网上检索了下相关问题,好像也不是很沾边

    于是又看了看代码,很明显发现ctrl点击的时候不跳转,鼠标悬浮其上出现的信息有问题。那就一定是引用有问题,就去看了import.

     

    当时我是这样写的

    这里是我偷懒,直接把上一行引用赋值下来,改了个名字。

     

     

     

     

     

    三、问题解决

    之前在网上检索的时候有看到说引用的时候没有加大括号,我就想是不是这个括号的原因,我就把打括号删掉试了下,结果是可以的。

    删除大括号

     

    这部分知识还是有缺失,就在网上进行检索,看到一篇文章,提及了这个问题。

    链接:https://blog.csdn.net/Chris__wang/article/details/82977626?utm_source=blogxgwz0

     

     

     

     

    四、总结

    总结一下,如果是用export default 抛出,就不能加大括号;如果只是用export就得加。简单来讲,就是有default不加大括号,没有要加

     

     

     

     

     

     

    展开全文
  • React.js所需三个js文件之2--react-dom.development.v17.js,在head引入script即可使用。
  • 错误代码: const numbers = [1,2,3,4,5]; const listItems = numbers.map(item => <li>{item}) ReactDOM.render( <ul>{listItems}, document.getElementById('example') ...记录一下,刚开始学react

    错误代码:

     			  const  numbers = [1,2,3,4,5];
                  const listItems = numbers.map(item => <li>{item}</li>)
                  ReactDOM.render(
                      <ul>{listItems}</ul>,
                      document.getElementById('example')
                  )
    

    修正后的代码:

      			 const  numbers = [1,2,3,4,5];
                 const listItems = numbers.map((item,key) => <li key={key}>{item}</li>)
                  ReactDOM.render(
                      <ul>{listItems}</ul>,
                      document.getElementById('example')
                  )
    

    区别
    就是一个key的原因

    记录一下,刚开始学react

    展开全文
  • react.js导航条by Marius Espejo 由Marius Espejo 如何在React.js生态系统中导航而不会迷路 (How to navigate the React.js ecosystem without getting lost) In the world of software development it’s often ...

    react.js导航条

    by Marius Espejo

    由Marius Espejo

    如何在React.js生态系统中导航而不会迷路 (How to navigate the React.js ecosystem without getting lost)

    In the world of software development it’s often hard to find one direct path for learning something new. Should you read a book? Follow a tutorial? Watch a video? Ask for advice?

    在软件开发领域,通常很难找到学习新事物的直接途径。 你应该读书吗? 遵循教程? 观看视频? 请教?

    With so many possible paths and options to take, getting lost is easy.

    有这么多可能的路径和选择,迷路很容易。

    Learning React.js is actually straightforward, all it takes is knowing which path to take.

    学习React.js实际上很简单,所要做的就是知道走哪条路。

    先决条件 (Prerequisites)

    Here are some things I recommend you get a solid grasp on before you start learning React.

    我建议您在开始学习React之前牢牢掌握以下内容。

    确保您对HTML和CSS有所了解 (Make sure you have some understanding of HTML and CSS)

    Pretty much every web development is going to require some form of knowledge of these two. If you’re an absolute beginner in this space, I would recommend checking out Travis Neilson’s videos like HTML5 Basics and CSS Basics. Then jump over to freeCodeCamp.org or codeacademy.com for some practice.

    几乎每个Web开发都需要这两种知识的某种形式。 如果您绝对是该领域的初学者,我建议您查看Travis Neilson的视频,例如HTML5 BasicsCSS Basics 。 然后跳到freeCodeCamp.orgcodeacademy.com进行一些练习。

    Your ultimate goal should be to take a basic design or structure for a web page, turn it into code, and visually see what you were hoping it would look like. Ideally, it will look very similar to your design.

    您的最终目标应该是为网页采取基本的设计或结构,将其转换为代码,并直观地看到您希望的外观。 理想情况下,它看起来与您的设计非常相似。

    掌握JavaScript本身 (Have a good grasp of JavaScript itself)

    I don’t recommend trying to learn frameworks and libraries before you’ve spent some time learning the JavaScript language first. There is a tremendous amount of resources out there to learn JavaScript depending on your experience.

    在您花一些时间先学习JavaScript语言之前,我不建议您尝试学习框架和库。 根据您的经验,这里有大量的资源来学习JavaScript。

    For an absolute beginner, freeCodeCamp has an awesome set of resources, including a video playlist of all the JavaScript basics and an interactive place to learn and practice right right on their website.

    对于一个绝对的初学者来说, freeCodeCamp拥有一系列很棒的资源,包括所有JavaScript基础的视频播放列表以及一个可以在其网站上直接学习和练习的交互式场所。

    The best way to learn code is to write code!

    学习代码的最好方法是编写代码!

    If you’ve already used JavaScript in the past and need a refresher checkout this re-introduction.

    如果您过去已经使用过JavaScript,并且需要复习一下,请参阅此重新介绍

    If you’re not sure if you do know JavaScript, then I bet You Don’t Know JS. That’s actually a popular book series that is helpful for those of you who are looking to get a better understanding of the language.

    如果您不确定自己是否懂JavaScript,那么我敢打赌, 您不懂JS 。 这实际上是一本受欢迎的丛书,对那些希望更好地理解该语言的人很有帮助。

    “When you strive to comprehend your code, you create better work and become better at what you do. The code isn’t just your job anymore, it’s your craft.”
    “当您努力理解代码时,您将创造更好的工作,并在做事上变得更好。 代码不再只是您的工作,而是您的工作。”
    — Jenn Lukas
    —珍妮·卢卡斯(Jenn Lukas)

    除了学习基本JavaScript外,您还需要对ECMAScript 2015(ES6)的某些功能有一个体面的了解。 (Beyond learning basic JavaScript, you’ll also need to get a decent understanding of some ECMAScript 2015 (ES6) features)

    Specifically, focus on understanding the following:

    具体来说,重点是了解以下内容:

    • Modules (import/export)

      模块(导入/导出)
    • let and const

      let和const
    • Arrow functions

      箭头功能
    • Classes

      班级
    • Destructuring

      解构
    • Rest/Spread

      休息/传播

    These are guaranteed to show up in your React code and having some understanding of them will allow you to consume documentation much easier.

    保证它们会出现在您的React代码中,并且对它们有一些了解将使您更轻松地使用文档。

    To get a quick start on these, I would recommend LearnCode.academy’s ES6 Cheatsheet or one of Babel’s resources.

    为了快速入门,我建议使用LearnCode.academy的ES6速查表或Babel的资源之一

    了解如何使用节点包管理器(npm) (Learn how to use the Node Package Manager (npm))

    Install Node.js and it will come with npm packaged with it. At the moment npm is one of the best ways to download JavaScript development dependencies.

    安装Node.js ,它将附带打包的npm。 目前,npm是下载JavaScript开发依赖项的最佳方法之一。

    For example, this simple command will allow you to install and download React for a project:

    例如,这个简单的命令将允许您为项目安装和下载React:

    npm install --save react

    Most of what you need to know initially is how to install packages. This alone will open you up to an extensive set of tools and libraries that will allow you to get more done in less time.

    最初,您需要了解的大多数信息是如何安装软件包。 仅此一项就为您打开了广泛的工具和库集,使您可以在更短的时间内完成更多工作。

    (可选)了解函数式编程的基础 ((Optional) Learn the basics of functional programming)

    Although it is not required to learn React, understanding basic functional programming concepts will come in handy many times in your React development.

    尽管不需要学习React,但在React开发中,很多时候都可以理解基本的函数编程概念。

    I would recommend understanding function composition, purity, and higher-order functions. The goal here is not to be an expert about the subject, but to be at least exposed to it. For a quick introduction, here’s an awesome talk from a great speaker. Or you can learn right from your inbox if you want to.

    我建议您了解函数的组成,纯度和高阶函数。 这里的目标不是成为该主题的专家,而是至少要对此有所了解。 为了快速介绍,这是一位出色演讲者的精彩演讲 。 或者,您可以根据需要直接从收件箱中学习。

    “Every mountain top is within reach if you just keep climbing.”
    “如果您继续攀登,每个山顶都近在咫尺。”

    Barry Finlay

    巴里·芬莱

    Depending on your development experience, you can learn React basics within a few hours to a few days. Beyond that it just takes a bit more experience and you’ll be able to create applications in no time.

    根据您的开发经验,您可以在几小时到几天内学习React基础知识。 除此之外,它还需要更多的经验,您将能够立即创建应用程序。

    How is that possible? Well…

    那怎么可能? 好…

    首先,不要学习Redux或其他库 (First of all, don’t learn Redux or other libraries yet)

    The biggest mistake a lot of people make when learning React for the first time is search for a starter template or a tutorial that already includes Redux and a bunch of other libraries in it.

    很多人在第一次学习React时犯的最大错误是搜索入门模板或教程,其中已经包含Redux和许多其他库。

    People often ask me what’s the best way to learn React. For some reason it never occurs to them that the official documentation is actually a great place to start because it focuses on teaching you just React.

    人们经常问我什么是学习React的最好方法。 出于某种原因,我从不给他们的正式文件实际上是一个很好的起点,因为它侧重于教导你React过来。

    Forget about Redux for now. You might not even need it.

    暂时忘记Redux。 您甚至可能不需要它

    Forget about other libraries and boilerplates.

    忘记其他库和样板。

    “Learning React by copying boilerplates is like learning to cook by eating food in fancy restaurants. It doesn’t work. You need to start with basics and ignore the fear of missing out.” — Dan Abramov

    “通过复制样板来学习React就像在高档餐馆吃食物来学习烹饪。 没用 您需要从基础开始,而忽略错过的恐惧。” — 丹·阿布拉莫夫

    只关注React和React。 (Focus on React and React alone.)

    I would recommend this for the same reason that you might not want to learn Calculus before becoming comfortable with Algebra. Or you might not even need Calculus to solve a simple math problem.

    我之所以建议这样做,是因为您可能不喜欢代数之前就不想学习微积分。 否则,您甚至不需要微积分即可解决简单的数学问题。

    Figure out what problems React can and can’t solve for you on its own. That will give you a basic guide to know when it’s time to pull in more libraries, and ultimately more things to learn, into your project.

    找出React可以为自己解决或不能为您解决的问题。 这将为您提供基本的指南,以了解何时该将更多的库以及最终更多的要学习的知识引入您的项目。

    这是最简单的入门方法 (Here’s the easiest way to get started)

    Start with create-react-app. It will give you everything you need to start small without being held back by boilerplate and configuration.

    create-react-app开始 。 它会为您提供从小处开始所需的一切,而不会受到样板和配置的限制。

    It allows you the freedom to focus on learning React on its own without having to worry about learning and setting up Webpack, Babel, and various other configuration.

    它使您可以自由地专注于自己学习React,而不必担心学习和设置Webpack,Babel和其他各种配置。

    npm install -g create-react-app create-react-app my-app
    cd my-app npm start

    Those four simple commands will get you everything you need to get a project started. It includes tooling that will refresh your browser when you change your code.

    这四个简单的命令将为您提供启动项目所需的一切。 它包含的工具可在您更改代码时刷新浏览器。

    It also offers a build command which will compile your code to a few static assets that you can easily deploy anywhere and an awesome user guide that will guide you through that process.

    它还提供了一个构建命令,该命令会将您的代码编译为一些可以轻松部署到任何地方的静态资产,并且还提供了一个很棒的用户指南 ,它将指导您完成该过程。

    I think of create-react-app as sort of like hiking boots. You don’t necessarily need hiking boots to climb a mountain, but they sure will help and might even make it easier to climb certain surfaces. And if you realize you don’t need them, you can always “eject” them from your feet!

    我认为create-react-app就像远足靴一样。 您不一定需要登山靴来爬山,但是它们肯定会有所帮助,甚至可能使某些表面的攀登变得更容易。 如果您意识到自己不需要它们,则可以随时从脚上“ 弹出 ”它们!

    With tooling out of the way, let’s get back on the path of learning React.

    随着工具的发展,让我们回到学习React的道路上。

    掌握React的基础知识 (Master the fundamentals of React)

    Check out this great post on the main concepts of React. There actually aren’t a lot of stuff you need to learn.

    查看关于React主要概念的精彩文章。 实际上,您不需要学习很多东西。

    In general you should get an understanding of the following:

    通常,您应该了解以下内容:

    • JSX: what it is, how it differs from traditional HTML, and how to declaratively set it up to handle dynamic changes

      JSX: 它是什么 ,它与传统HTML有何不同,以及如何以声明方式设置它以处理动态更改

    /* Notice how you have to use className instead of class     And how the expression inside the curly braces allow it to    dynamically handle any name passed in via props */
    <h1 className="greeting">Hello, {this.props.name}</h1>
    // These are really just simple functions which return JSXfunction MyComponent(props) {      return <h1 className="greeting">Hello, {props.name}</h1>; }
    // Alternatively write them using arrow functionsconst MyComponent = (props) => (<h1 className="greeting">Hello, {props.name}</h1>);
    • Learn how to write components using the ES6 class syntax. It allows you to write more complex components with access to lifecycle hooks and local state

      了解如何使用ES6类语法编写组件。 它允许您编写更复杂的组件,并可以访问生命周期挂钩和本地状态

    class MyComponent extends React.Component {      render() {          return <h1 className="greeting">Hello, {this.props.name}</h1>;      } }
    • Make sure you have a good understanding of state and how to properly use it. Understanding the pros and cons of using a component’s local state will give you the mental building blocks for when, and when not to, use a different state management solution

      确保您对状态及其正确使用方式有很好的了解。 了解使用组件的本地状态的利弊,将为您在何时以及何时不使用其他状态管理解决方案方面提供思路上的基础

    • Learn how to write and use the component lifecycle hooks and when each one may be useful

      了解如何编写和使用组件生命周期挂钩以及何时使用每个挂钩

    class MyComponent extends React.Component {   // A couple examples of hooks that I've had to use a lot:
    componentDidMount() {      /* useful for initializing or triggering events after the          component renders to the DOM */                                   }          shouldComponentUpdate() {     /* useful for performance purposes and preventing redundant           re-rendering */   }      componentWillReceiveProps() {     /* useful for when you need to trigger changes when new props             come in */   }      render() {          return <h1 className="greeting">Hello, {this.props.name}</h1>;      } }
    • Learn how to use PropTypes. It’s an easy way to get some basic type checking added to your components

      了解如何使用PropTypes 。 这是将一些基本类型检查添加到组件中的简便方法

    import PropTypes from 'prop-types';
    class MyComponent extends React.Component {      render() {          return <h1 className="greeting">Hello, {this.props.name}</h1>;      } }Greeting.propTypes = {    name: PropTypes.string };

    了解如何构建代码 (Learn how to structure your code)

    Once you have the fundamentals down you’ll want to start thinking about how your code is structured.

    掌握了基础知识之后,您将开始考虑代码的结构。

    Look into the concept of Container and Presentational components. Doing so will help you to understand how to better separate concerns within your React code.

    研究容器和表示组件的概念。 这样做将帮助您了解如何更好地在React代码中分离关注点。

    If you decide to incorporate a state management solution in the future, such as Redux, then Container components will help with that transition. You’ll know that most of the data passed around your application are coming from containers.

    如果您决定在将来合并诸如Redux之类的状态管理解决方案,那么Container组件将帮助实现这一过渡。 您会知道,围绕应用程序传递的大多数数据都来自容器。

    If you haven’t already, also think about your folder structure. As your codebase starts to grow, consider how well your folder structure scales.

    如果还没有,请考虑一下您的文件夹结构。 随着代码库开始增长,请考虑文件夹结构的扩展程度。

    Are files easy to find?

    文件容易找到吗?

    If you’re working with a team, are they able to intuitively know where specific components are?

    如果您与团队合作,他们是否能够直观地知道特定组件在哪里?

    Note that you don’t have to have your code in a specific structure immediately. Try to get into the habit of refactoring and improving your code as you learn each of these concepts.

    请注意,您不必立即将代码放在特定的结构中。 在学习这些概念时,请养成重构和改进代码的习惯。

    “I’m not a great programmer; I’m just a good programmer with great habits.”
    “我不是一个伟大的程序员; 我只是一个有良好习惯的优秀程序员。”
    — Kent Beck
    肯特·贝克

    构建解决实际问题的应用程序 (Build an application that solves a real problem)

    The best and true way to deeply understand React is by building something with it.

    深入理解React的最好,真实的方法是通过构建一些东西。

    Try to build something that will actually motivate you to work on it and avoid creating things that you probably already know the solution to.

    尝试构建一些可以真正激发您进行工作的东西,并避免创建可能已经知道解决方案的东西。

    • Try to incorporate some sort of external data (maybe make an api call) and figure out how to get that data to properly flow throughout your application, taking full advantage of state and props

      尝试合并某种外部数据(也许进行api调用),并弄清楚如何充分利用状态和道具来使这些数据正确地流遍整个应用程序
    • Consider integrating react-router once you have the need to have multiple pages to your application

      一旦需要在应用程序中包含多个页面,请考虑集成react-router

    • Use some component libraries to get up and running quickly with a basic look and feel. Know that this amazing JavaScript ecosystem that we have with npm and Github allows you to easily incorporate ready-to-use components into your application

      使用一些组件库以基本的外观快速启动并运行。 知道我们与npm和Github一起拥有的这个惊人JavaScript生态系统使您可以轻松地将现成的组件整合到您的应用程序中
    • Deploy your application somewhere. There are so many different ways that you can deploy your code for free. Try one out. There is nothing cooler than seeing your work be deployed out to the internet and being able to share that link to someone else

      将您的应用程序部署到某个地方。 您可以通过多种不同方式免费部署代码。 尝试一下。 没有比将您的工作部署到互联网并能够将链接共享给其他人更酷的了

    If you have gotten this far, that’s awesome! Look back at your progress and be proud of it.

    如果您走到了这一步,那就太棒了! 回顾自己的进步,并为此感到自豪。

    Hungry for more? Here’s a couple tips.

    渴望更多? 这里有一些提示。

    测试您的代码! (Test your code!)

    Make sure you learn how to test your code as early as possible. Use Jest (or your favorite test runner) and Enzyme.

    确保您学会了如何尽早测试代码。 使用Jest (或您最喜欢的测试跑步者)和Enzyme

    Jest and Enzyme are fairly easy to learn and can actually help you to understand how your components work in isolation.

    Jest和Enzyme非常易于学习,实际上可以帮助您了解组件如何独立工作。

    On top of that, tests make your code safer to refactor and improve, while also serving as dynamic documentation for your components.

    最重要的是,测试可以使您的代码更安全地进行重构和改进,同时还可以作为组件的动态文档。

    使用高级状态管理 (Use advanced state management)

    Does it feel like your state management with setState is becoming too complex? Are you constantly passing props down to multiple levels of descendant components?

    感觉您使用setState的状态管理变得太复杂了吗? 您是否不断将道具传递到多个子孙组件级别?

    Time to learn Redux or another flavor of Flux! You’ll need to understand what benefits a state management system brings to the table, and when or when not to use it.

    是时候学习Redux或Flux的另一种风味了! 您需要了解状态管理系统为表带来的好处,以及何时或何时不使用它。

    不要重复自己 (Don’t repeat yourself)

    If you find yourself writing the same code in multiple places, see if you can instead leverage other strategies for reusing logic. Learn how to create and use Higher-Order Components. This is an advanced technique for reusing component logic. It will improve your knowledge when it comes to component composition.

    如果发现自己在多个地方编写相同的代码,请查看是否可以利用其他策略来重用逻辑。 了解如何创建和使用高阶组件 。 这是重用组件逻辑的高级技术。 在组件组成方面,它将提高您的知识。

    升级 (Leveling up)

    In reality, the list never ends.

    实际上,列表永远不会结束。

    There are constantly new things that you can learn to improve and add to your applications and skillset.

    您可以学习不断改进的新事物,并将其添加到应用程序和技能中。

    If you focus on the basics and do most of the above, I believe that you’ll already be on a good path not only with React, but also front-end and JavaScript development in general.

    如果您专注于基础知识并完成上述大部分操作,那么我相信您不仅将在React方面走上一条好路,而且在总体上也将进行前端和JavaScript开发。

    The JavaScript ecosystem is constantly changing. Keep yourself in the mindset of continuously learning. Keep trying things and find out what works best for you.

    JavaScript生态系统不断变化。 保持不断学习的心态。 继续尝试并找出最适合您的方法。

    Going forward, your experience will help guide you on what to do next.

    展望未来,您的经验将帮助您指导下一步的工作。

    Thanks for reading! If you found this post useful, drop some ?? ???? on this post so others can find it!

    谢谢阅读! 如果您发现此帖子有用,请放一些?? ???? 在此帖子上,以便其他人可以找到它!

    翻译自: https://www.freecodecamp.org/news/how-to-navigate-the-react-js-ecosystem-without-getting-lost-43db14b00e08/

    react.js导航条

    展开全文
  • react-dom.development.js

    2020-10-15 11:23:28
    听说你在找react-dom.development.js这个文件,在带走它前记得收藏加点赞、听说你在找react-dom.development.js这个文件,在带走它前记得收藏加点赞、听说你在找react-dom.development.js这个文件,在带走它前记得...
  • You will begin by understanding the path breaking concepts of React.js, which makes it distinctive. You will set up React Native and begin exploring the anatomy of React Native apps. You’ll also ...
  • 这是React.js的简单演示... script src =" ../build/react.development.js " > </ script > < script src =" ../build/react-dom.development.js " > </ script > < script src =" ../build
  • react.js essentials

    2018-03-04 13:20:07
    If so, React.js is what you've been looking for. The declarative nature of React.js will help you build a UI for large applications with data that changes over time. As a professional iOS and ...
  • !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Babel=t():e.Babel=t()}(this,...
  • React是用于构建用户界面的JavaScript库,JavaScript的库分别是:AnglarJS2,React,Jquery; 我使用的是CDN(要是开发阶段...script src="https://cdn.staticfile.org/react/16.4.0/umd/react.development.js"><...

    React是用于构建用户界面的JavaScript库,JavaScript的库分别是:AnglarJS2,React,Jquery;

    我使用的是CDN(要是开发阶段,尽量不要用下面CDN,因为慢慢慢慢慢。。。悠悠):

    <script src="https://cdn.staticfile.org/react/16.4.0/umd/react.development.js"></script>
    <script src="https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js"></script>
    <script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>

    元素渲染:

    输出:const element=<h1></h1>

    将元素渲染到DOM中:<div id=""></div>

    要将React元素渲染到根DOM节中,用React.DOM将其渲染到页面上;React的注释格式是:{/**/}:

    <div id="demo"></div>
    <script type="text/bable">{/*type这里一定要写*/}
    conter element=<h1>Hello</h1>;
    ReactDOM.render(
    element,
    document.getElementById('demo')
    );
    </script> 

    更新元素渲染:

    React元素不能被更改,只有建立一个新的元素,将其传入进去,React元素会只更新被修改的内容。

    <body>
    <div id="demo"></div>
    </body>
    <script type="text/babel">
    {/*Component:ES6类,封装要展示的东西*/}
        class Clock extends React.Component {
            render() {
                return (
                        <div>
                            <h1>Hello, world!</h1>
                            <h2>现在是 {this.props.date.toLocaleTimeString()}.</h2>
                        </div>
                );
            }
        }
    function tick() {
        ReactDOM.render(
                <Clock date={new Date()}/>,
            document.getElementById('demo')
        );
    }
    setInterval(tick, 1000);
    
    </script>

     

    JSX:是React用来代替常规的javaScript;

    使用JSX

     

    ReactDOM.render(
        <h1>Hello, world!</h1>,
        document.getElementById('example')
    );

    使用多个嵌套(要使用<div></div>进行包裹):

    <div>
    <h1>hello</h1>
    <h2>React</h2>
    <p data-myattribute = "somevalue">这是一个很不错的 JavaScript 库!</p>
    </div>
        ,
        document.getElementById('demo')
    );

    样式:

    <div id="demo"></div>
    <script type="text/babel">
        var myStyle = {
        fontSize:100,
        color:'#ff0000'
        };
    ReactDOM.render(
    <h1 style={myStyle}>你好</h1>,
    document.getElementById('demo')
    );
    </script>

    外部使用:

    HTML文件:

    <div id=demo></div>
    <script src="JSX.js" type="text/babel"></script>

    JSX.js文件 为"p"添加自定义,需要加入"data-":

    ReactDOM.render(
    <div>
    <h2>欢迎学习 React</h2>
    <p data-myattribute = "somevalue">这是一个很不错的 JavaScript 库!</p>
    </div>
        ,
        document.getElementById('demo')
    );

    JavaScript表达式

    <div id="demo"></div>
    <script type="text/babel">
        var i=1;
        ReactDOM.render(
            <div>
                <h1>{i == 1 ? 'true':'false'}</h1>
                {/*注释写在花括号里,不能使用if else判断语句,使用三元算法*/}
            </div>
            ,
            document.getElementById("demo")
        );
    </script>

    数组

    <div id="demo"></div>
    <script type="text/babel">
        var val=[
            <h1>1</h1>,
            <h2>2</h2>,
            <h3>3</h3>,
        ];
        ReactDOM.render(
                <div>{val}</div>,
            document.getElementById('demo')
        );
    </script>

    组件:

    下面使用的是函数定义的组件:

     function Hellomi(props) {
            return <h1>hihao{props.name}</h1>;
        }
    
        const element = <Hellomi name="dfg"/>;
        ReactDOM.render(
            element,
            document.getElementById('demo')
        );

    使用ES6 class定义组件:

    class Welcome extends React.Component {
      render() {
        return <h1>Hello World!</h1>;
      }
    }

     PS:原生的HTML元素名是以小写字母开头的,但在自定义React类名以大写字母开头的。

    name属性通过props.name来获取。在添加属性时,class属性需要写className,for属性需要写classFor;class和for是JavaScript的保留字。

    复合组件:

    function Name(props) {
            return <h1>姓名:{props.name}</h1>;
        }
    
        function Six(props) {
            return <h1>性别:{props.six}</h1>;
        }
    
        function Password(props) {
            return <h1>密码{props.password}</h1>;
        }
    
        function App() {
            return (
                    <div>
                        <Name name="黎明"/>
                        <Six six="女"/>
                        <Password password="1234"/>
                    </div>
            );
        }
    
        ReactDOM.render(
                <App/>,
            document.getElementById('example')
        );

    PS:创建多个组件合并成一个组件,把组件的不同点进行分离。

     

     

     

    展开全文
  • by Margarita Obraztsova 玛格丽塔... 如何使用Webpack 4简化React.js开发过程 (How to streamline your React.js development process using Webpack 4) In the real world of development, we have to add ...
  • react and react dom js.zip

    2020-07-04 11:48:06
    开发react必须的react.development.js文件,react-dom.development.js文件,方便开发人员快速开发,react js用的最新版本16.13
  • 单选框 <!DOCTYPE html> <html> <head> <meta charset="UTF-8" />...script src="https://cdn.staticfile.org/react/16.4.0/umd/react.development.js"></script> <script src.
  • (node_modules/mobx-react/dist/mobxreact.cjs.development.js:10:16) Test Suites: 1 failed, 1 total Tests: 0 total Snapshots: 0 total Time: 1.401s Ran all test suites. npm ERR! Test failed. See above ...
  • at constructClassInstance (react-dom.development.js?cada:6355) at updateClassComponent (react-dom.development.js?cada:7839) at beginWork (react-dom.development.js?cada:8225) at performUnitOfWork ...
  • react-dom.development.js:500 Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscript...
  • 带有Firebase CRUD的React.js 代码 所有代码都在src文件夹中。 使用 下载zip文件后。 使用cmd或终端。 cd to this folder and npm run start // it will run a development web with localhost:3000 npm run build ...
  • 1.最简单的开始: ... 只需要添加三个相关的react库文件,就可以直接使用react了。 <script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script> <s
  • <p><strong>react.component</strong> triggers <p><img alt="screen shot 2017-02-08 at 7 35 47 pm" src="https://img-blog.csdnimg.cn/img_convert/c2ecda781236963cff2efb985eb6e448.png" /></p> <p><strong>...
  • 导语: 背景:编写前端React代码遇到的问题。 原因:在render函数里,直接调用this.setState改变state。...export default class MaxUpdateDepthExceeded extends React.Component { constructor(pro.
  • at HTMLUnknownElement.callCallback (react-dom.development.js:149) at Object.invokeGuardedCallbackDev (react-dom.development.js:199) at invokeGuardedCallback (react-dom.development.js:256) at ...
  • at useMemo (react.development.js:1525) at TakeNotes (index.tsx:18) </code></pre> <p><img alt="Screenshot 2019-06-24 at 12 55 55" src=...
  • 代码 <!DOCTYPE html> <html lang="en"> <head>...meta charset="UTF-8">...script src="../js/react.development.js"></script> <script src="../js/react-dom.development.js"&
  • react相关.zip

    2019-10-13 00:11:42
    babel.min.js + react.development.js +react-dom.development.js

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 3,003
精华内容 1,201
关键字:

react.development.js