我创建了一个非常简单的 ASP.NET CORE 2.0 项目并选择了新的 Razor Page模板,然后我从主页中删除了所有内容并添加了 Paper-button web组件以便使用它以下是我的 Index.cshtml
的代码page
@model IndexModel
@{
ViewData["Title"] = "Home page";
}
<paper-button raised>My Button</paper-button>
然后我在我的文件 Layout.cshtml 中添加了此组件的import语句,如下所示:这就是它现在的样子:
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, minimum-scale=1,
initial-scale=1, user-scalable=yes">
<title>@ViewData["Title"] - DineAlong</title>
//notice the following script for pollyfills and then the import for paper-button
<script src="/bower_components/webcomponentsjs/webcomponents-loader.js">
</script>
<link rel="import" href="/bower_components/paper-button/paper-button.html">
<environment include="Development">
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" href="~/css/site.css" />
</environment>
<environment exclude="Development">
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css"
asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
<link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
</environment>
</head>
运行html页面后,只显示文字 MyButton ,并且不显示该地方的纸质按钮。
注意:**我有一个** bower_components 文件夹以及Layout.cshtml和Index.cshtml,即:在 Pages文件夹内,因此布局文件中的引用导入应该工作得很好。
以下是控制台中的错误我可以看到错误,但我不知道它为什么会发生。
文件夹结构