简体   繁体   English

将默认主文件“index.js”更改为 React 中的其他文件?

[英]Changing the default main file "index.js" to some other file in react?

I have been thinking about the topic of changing the main file in react but I couldn't get through.我一直在想在react中更改主文件的主题,但我无法通过。 Please, Can anyone explain whether can we change, if not then why.拜托,任何人都可以解释我们是否可以改变,如果不能那么为什么。

If it is app.js you can change any file to render a root id div in react app如果它是 app.js 你可以更改任何文件以在 React 应用程序中呈现根 id div

If you want to change app.js you can change the following line in index.js file如果你想更改 app.js,你可以在index.js文件中更改以下行

ReactDOM.render(
  <React.StrictMode>
    <App /> // Change To Your Default File
  </React.StrictMode>,
  document.getElementById('root')
);

I assume you are referring to create-react-app.我假设您指的是 create-react-app。 In which case the answer is no: https://create-react-app.dev/docs/folder-structure .在这种情况下,答案是否定的: https://create-react-app.dev/docs/folder-structure

You can always eject a create-react-app, but IMO it is not really worth it unless you need some really specific configuration.你总是可以弹出一个 create-react-app,但在我看来,这并不值得,除非你需要一些非常具体的配置。

Keep in mind that you don't have to use create-react-app to use react proper .请记住,您不必使用create-react-app来使用react proper If you use react by itself, you can apply any organization you wish.如果你单独使用 React,你可以应用任何你想要的组织。

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

相关问题 如何在主文件Index.js中使用对象参数调用模块 - How to call module with object Parameter in main file Index.js node.js如何从index.js执行其他js文件? - nodejs how to execute other js file from index.js? 有人能解释一下如何在本地单独的文件中有一些命令,然后是 Discord.js 的主要 index.js 吗? - Can someone explain how to have some commands in a seperate file locally then the main index.js for Discord.js? 在Flutter Webview中运行一些Javascript文件,例如index.js - Run some Javascript file like index.js in Flutter Webview 如何配置我的 index.js 文件以支持我的 React Native 应用程序的乌尔都语、英语、荷兰语和其他语言 - How do I configure my index.js file to support Urdu, English, Dutch and other languages of my react native application React:main.js 和 index.js 基本一样吗? - React: Is main.js basically the same as index.js? 无法将类导入 index.js 文件 - Cannot import class into index.js file 在Express.js应用中排除来自index.js文件的默认路由 - Exclude default routes form index.js file in Express.js app React.js:如何使用源文件中index.js中加载的json数据? - React.js: how to use json data that is loaded in index.js in source file? React js。 将道具传递到index.js文件会给我一个“未定义”错误 - React js. Passing Props to the index.js file gives me an 'undefined' error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM