【问题标题】:Are there any obvious reasons my node.js react app is not recognizing any index.html file?我的 node.js react 应用程序无法识别任何 index.html 文件是否有任何明显的原因?
【发布时间】:2019-08-10 16:33:50
【问题描述】:

您可以在此处查看应用程序:https://02e7822e.ngrok.io

git repo

我的主要问题是 index.html 不知何故从未被连接起来,这意味着

1) 该网站根本无法针对移动设备进行扩展

2) 没有网站图标

我遗漏了什么明显的东西吗?我以前建过网站,但是每次index.js看起来都有些不同,这里供大家参考:

import AppBar from '../components/AppBar';
import Block from '../components/Block';
import React from "react";

class Index extends React.Component {
    render() {

        return (
            <div>
                <AppBar/>
                <Block/>
            </div>
        )
    }
}

export default Index;

在以前的网站中,我已经能够使用 ReactDOM 和 document.getElementByID 来(我认为)对 index.html 进行某种引用,但我尝试过,只是出现语法错误。

【问题讨论】:

    标签: javascript html node.js reactjs


    【解决方案1】:

    所以看起来你使用了create-react-app 并改变了文件夹结构......不要那样做。

    这里是官方文件夹结构的链接:

    https://facebook.github.io/create-react-app/docs/folder-structure

    还有。在将服务器与 React 一起使用时,我看到了一个文件夹结构,其中服务器保存在应用程序的根目录中,然后 React 保存在单独的 client 文件夹中。

    my-main-app-folder
    
    my-main-app-folder/
      client/ (This is the folder where React lives)
        public/
          index.html
          favicon.ico
        node_modules/
        src/
          App.js
          index.js
        package.json
        README.md
      .gitignore
      server.js
      package.json
      package-lock.json
      README.md
    

    类似的东西

    【讨论】:

    猜你喜欢
    • 2021-02-02
    • 2012-05-23
    • 1970-01-01
    • 2021-01-14
    • 2022-01-22
    • 2016-03-20
    • 1970-01-01
    • 2020-05-29
    • 1970-01-01
    相关资源
    最近更新 更多