How to use fallback source on ScriptTagHelper and

2019-05-14 02:56发布

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条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-05-14 03:22
<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.

查看更多
登录 后发表回答