2017-10-28 110 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 =」 /「>和。非常感謝! –