简体   繁体   English

React dom-从src / app.js渲染到public / scripts / app.js

[英]React dom - rendering from src/app.js to public/scripts/app.js

I'm starting to learn React DOM. 我开始学习React DOM。 I'have installed all components correctly few days ago and my firt app used to work correctly. 我几天前已经正确安装了所有组件,并且我的firt应用程序过去可以正常工作。

Now I have a problem with render from src/app.js to public/scripts/app.js in my app. 现在我在应用程序中从src / app.js到public / scripts / app.js的渲染存在问题。 When I modify src/app.js - there is no rendering to public/scripts/app.js . 当我修改src / app.js时-没有渲染到public / scripts / app.js。

My live server is working correctly and is ready for changes, but when I save changes of src/app.js, that doesn't modify the public/scripts/app.js . 我的实时服务器可以正常工作并且可以进行更改,但是当我保存src / app.js的更改时,这不会修改public / scripts / app.js。

I'm on Windows.. 我在Windows上。

Thanx for help. 感谢您的帮助。

Your main file inside app.js inside scripts does not aware of the changes you make in the App.js file in src. 脚本内app.js内的主文件不知道您在src中的App.js文件中所做的更改。 React does not give this feature. React没有提供此功能。 You need to do it manually. 您需要手动进行。 For which You need to install Babel in your package.json file. 为此,您需要在package.json文件中安装Babel Open terminal having the path of your file location and install Babel-Cli there. 打开具有您文件位置路径的终端,然后在其中安装Babel-Cli

npm install babel-cli --save

Now, open another terminal with your file location path and hit the command below: 现在,使用您的文件位置路径打开另一个终端,然后单击以下命令:

babel src/App.js --out-file=public/scripts/app.js --presets=env,react -watch

Now leave this terminal as it is. 现在,将此终端保持原样。 It will transpile your ES6 javascript from src to scripts folder. 它将您的ES6 javascript从src转换到scripts文件夹。 Make sure to leave that terminal open while you are working. 确保在工作时将该终端保持打开状态。 Hope this works. 希望这行得通。

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

相关问题 React Router Dom 组件在 App.js 中呈现,但不是作为单独的组件 - React Router Dom components rendering in App.js, but not as separate component 错误:./src/App.js 尝试导入错误:“Switch”未从“react-router-dom”导出 - Error: ./src/App.js Attempted import error: 'Switch' is not exported from 'react-router-dom' ./src/App.js 尝试导入错误:“Switch”未从“react-router-dom”导出 - ./src/App.js Attempted import error: 'Switch' is not exported from 'react-router-dom' 外部 React 组件未在 App.js 中呈现 - External React components are not rendering in App.js React 功能组件未在 App.js 中呈现 - React functional components not rendering in App.js 在 App.js 文件中作为道具传递时,图像未在 DOM 中呈现? - Image is not rendering in the DOM while passing as props in the App.js file? 在./src/App.js'store'中的反应错误未定义 - react Error in ./src/App.js 'store' is not defined react-router-dom 没有加载 app.js 中的第四个元素 - react-router-dom not loading the fourth element in app.js 在同一个app.js中呈现来自不同HTML页面的多个DOM元素 - Rendering multiple DOM elements from different HTML pages in the same app.js 如何从 React JS 的公共文件夹中的 App.js 文件调用 function - How to call function from App.js file inside public folder in React JS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM