2016-04-10 36 views
0

我已經創建了一個Polymer元素,如下所示。聚合物在http服務器上不顯示任何東西

你好-world.html

<link rel="import" href="../bower_components/polymer/polymer.html"> 

<dom-module id="hello-world"> 

    <template> 
     <p><h1>Hello World</h1></p> 
    </template> 

    <script> 
     Polymer ({ is: "hello-world", }); 
    </script> 

</dom-module> 

加載它是如下的HTML文件: 的index.html

<!DOCTYPE html> 

<html> 
    <head> 
     <script src="bower_components/webcomponentsjs/webcomponents.js"></script> 

     <link rel="import" href="elements/hello-world.html"> 
    </head> 

    <body> 
     <hello-world></hello-world> 
    </body> 
</html> 

在命令提示,我存在的文件夾中(C: \用戶\管理\聚合物)包含index.html和我已經安裝在該文件夾中的http服務器,並已啓動服務器與

http-server C:\Users\Admin\polymer 

啓動localhost:8080/index.html將顯示一個空白網頁。需要解決的問題在哪裏?

回答

0

你說你的html文件是hello-world.html。但您正嘗試訪問localhost:8080/index.html。看到不同?訪問localhost:8080/hello-world.html或將hello-world.html重命名爲index.html

+0

感謝您的回答。然而,我提到聚合物元素是用'hello-world.html'寫成的。和'index.html'正在訪問它。 –

0

問題出在我在地址欄中輸入的URL。我必須鍵入「localhost:8080/polymer /」,其中polymer是包含index.html的文件夾。

我改爲輸入'localhost:8080/index.html',這是錯誤的。 Rando的回答幫助我弄清楚了這一點。感謝Rando!