javascript - 反应不会在我的窗口上呈现任何内容
问题描述
{
"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”消息显示在我的窗口上,但只出现空白页。我应该如何解决以获得更好的结果?
解决方案
你有错别字:
在 package.json 中修复:
"main": "./tmp/main/index.js",
在 index.html 中修复:
require("./tmp/renderer/app.js")