试图在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