将WinJS与ASP.NET MVC6集成

时间:2015-07-22 12:54:33

标签: visual-studio gulp bower winjs

我正在尝试将WinJS与使用最近的Visual Studio 2015创建的ASP.NET MVC6应用程序集成,并显示链接的工具提示。但它不起作用。

输出应如下所示:

enter image description here

以下是该应用的不同部分的外观:

bower.json:

{
  "name": "ASP.NET",
  "private": true,
  "dependencies": {
    "bootstrap": "3.0.0",
    "bootstrap-touch-carousel": "0.8.0",
    "hammer.js": "2.0.4",
    "jquery": "2.1.4",
    "jquery-validation": "1.11.1",
    "jquery-validation-unobtrusive": "3.2.2",
    "winjs": "4.1.0"
  }
}

gulpfile.js 没有变化。

将这些添加到 _Layout.cshtml

<link rel="stylesheet" href="~/lib/winjs/css/ui-light.css" />
<script src="~/lib/winjs/js/base.js"></script>
<script src="~/lib/winjs/js/ui.js"></script>

我的HTML代码是:

<div class="row">
    <div data-win-control="WinJS.UI.Tooltip"
         data-win-options="{innerHTML: 'Microsoft Corporation<br><span class=\'win-text-domain\'>www.microsoft.com</span>'}"
         style="margin-top: 20px;margin-bottom:30px">
        <span class="win-link">Microsoft</span>
    </div>
</div>

wwwroot \ js \ site.js

// Write your Javascript code.

WinJS.UI.processAll();

winjs

1 个答案:

答案 0 :(得分:0)

我在 site.js 中添加了以下代码。

(function () {
    WinJS.UI.processAll();
})();

然后将site.js包含在开发环境中。

<environment names="Development">
    <script src="~/lib/jquery/dist/jquery.js"></script>
    <script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
    <script src="~/lib/hammer.js/hammer.js"></script>
    <script src="~/lib/bootstrap-touch-carousel/dist/js/bootstrap-touch-carousel.js"></script>
    <script src="~/lib/winjs/js/base.js"></script>
    <script src="~/lib/winjs/js/ui.js"></script>
    <script src="~/js/site.js" asp-file-version="true"></script>
</environment>