試圖在Visual Studio社區中的ASP.NET 5中製作自定義聚合物元素。我選擇「新建項目」 - >「Web」 - > ASP.NET核心Web應用程序(.NET Core)。在Solution Explorer中我添加了一個新的文件「的helloworld.html」,在該文件中創建一個新的聚合物元件使用此代碼:ASP.net中的聚合物5
<link rel="import" href="https://polygit.org/components/polymer/polymer.html">
<dom-module id="hello-world">
<style></style>
<template>
<h1>Hello world</h1>
</template>
</dom-module>
<script>
Polymer({
is: "hello-world"
});
</script>
接下來,我嘗試實施(補充)這個元素的DOM是是由ASP.NET 5創建的,所以我對這兩個文件進行了更改index.cshtml和_layout.cshtml。
文件index.cshtml是:
@{
ViewData["Title"] = "Home Page";
}
<link rel="import" href="~/helloworld.html"/>
<div class="row">
<hello-world></hello-world>
</div>
在_layout.cshtml我添加的兩行代碼:
<link rel="import" href="https://polygit.org/components/polymer/polymer.html">
<script src="https://polygit.org/components/webcomponentsjs/webcomponents-lite.js"></script>
接下來,我點擊了調試,但沒有的Hello World屏幕。只有頁眉和頁腳從_layout.cshtml
在「應用程序Insights Request GET」中,在調試時,有以下注釋:_response code 404_。旁邊還有一顆紅色鑽石。 –
請不要使用ASP.NET 5標記,它不會再這樣調用。它是ASP.NET Core並且支持1.0的版本。* – Tseng