How to use fallback source on ScriptTagHelper and LinkTagHelper correctly

≡放荡痞女 提交于 2019-12-22 08:34:01

问题


I have read following posts from Damian Edwards.

https://github.com/aspnet/Mvc/issues/1576

https://github.com/aspnet/Mvc/issues/1580

At the ScriptTagHelper, I'm not sure what I should enter on asp-fallback-test attribute? It's the same as for jQuery? window.jQuery? How do I find the correct JavaScript Expression? Can someone give me an example based on moment-withlocales.min.js? Thanks!

Is following example for the LinkTagHelper correct?

<link
  rel="stylesheet"
  href="https://cdn.jsdelivr.net/bootstrap.daterangepicker/2/daterangepicker.css"
  asp-fallback-href="~/lib/bootstrap-daterangepicker/daterangepicker.css"
  asp-fallback-test-class="daterangepicker"
  asp-fallback-test-property="position"
  asp-fallback-test-value="absolute"
/>

Michael.


回答1:


<script src="//whatever.cdn.com/moment.js"
    asp-fallback-src="lib/moment.js"
    asp-fallback-test="window.moment">

The fallback test is some function in the js file that will be defined by the js script. If the function is undefined then it loads the fallback script.



来源:https://stackoverflow.com/questions/40626754/how-to-use-fallback-source-on-scripttaghelper-and-linktaghelper-correctly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!