2017-10-28 108 views
0

我正试图创建一个聚合物的电子应用程序。我试图导入一个自定义元素使用电子与进口(聚合物)

<link rel="import" href="src/lux-app.html"> 

但它没有工作。控制台说:

GET file:///D:/src/lux-app.html net::ERR_FILE_NOT_FOUND 

它没有使用正确的路径。我研究并发现,只有在服务器上(例如localhost),导入才能工作。有没有办法在电子或类似的东西中运行localhost?

谢谢

编辑: 这里是文件结构

lux-app 
    |── bower_components 
    |── images 
    |── lib 
     └── artnet.js 
    |── lux-app.html 
    |── .gitignore 
    |── bower.json 
    |── ... 
node_modules 
    └── node stuff 
main.js 
index.html 
polymer.json 
package.json 
README.json 
renderer.js 

回答

1

进口工作,没有 “本地主机”,正如我在"Electron Api demos"看到。在的index.html文件,还有一些进口这样的:

<link rel="import" href="sections/about.html"> 
<link rel="import" href="sections/windows/windows.html"> 
<link rel="import" href="sections/windows/crash-hang.html"> 
<link rel="import" href="sections/menus/menus.html"> 

所以,我认为你的问题是,在主渲染器路径变量(main.js)不工作或者如果您尚未声明该变量,则需要使用const path = require('path')并使用Electron Api演示中main.js文件中的路径。

(我不是用电子方面的专家,但我认为我可以让你面向解决方案在寻找电子API回购里面的文件)

+1

它的工作,但我不得不删除<基地HREF =” /“>和。非常感谢! –