反应不会在我的窗户上呈现任何东西

问题描述 投票:0回答:1
{
 "name": "app",
 "version": "1.0.0",
 "description": "",
 "main": ".tmp/main/index.js",
 "scripts": {
 "start": "electron ."
 },
 "author": "",
 "license": "MIT",
 "devDependencies": {
 "babel-cli": "^6.18.0",
 "babel-preset-es2015": "^6.18.0",
 "babel-preset-react": "^6.16.0",
 "electron": "^1.6.1"
 },
 "dependencies": {
 "firebase": "^5.8.6",
 "photon": "github:connors/photon",
 "react": "^15.4.2",
 "react-dom": "^15.4.2",
 "react-router": "^3.0.0"
 }
}

这是我的package.json文件

import React from "react";
import {render} from "react-dom";

render(<div>Hello. Electron and React JSX</div>,document.getElementById("app"));

这是我的app.jsx文件。

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Electron chat</title>
        <link rel="stylesheet" href="node_modules/photon/dist/css/photon.css">
    </head>
    <body>
        <div class="window">
            <div id="app" class="window-content"></div>
        </div>
        <script>require("./.tmp/renderer/app.js")</script>
    </body>
</html>

这是我的index.html代码。我希望我的jsx文件的“Hello.Electron and React JSX”消息显示在我的窗口上,但只显示空白页面。我应该怎样修复以获得更好的结果?

javascript reactjs electron react-dom
1个回答
0
投票

你有错别字:

修复package.json:

"main": "./tmp/main/index.js",

修复index.html:

require("./tmp/renderer/app.js")
© www.soinside.com 2019 - 2024. All rights reserved.