How do ASP.NET Core's “asp-fallback-*” CDN tag helpers work?

前端 未结 2 1654
南旧
南旧 2020-12-15 18:51

I understand what the asp-fallback-* tag helpers do. What I don\'t understand is how.

For example:



        
2条回答
  •  -上瘾入骨i
    2020-12-15 19:42

    Ok I think I get it now, by combining @KirkLarkin's answer and common sense.

    The sr-only is applied to a hidden meta element. If bootstrap is loaded then that element would get a css value of position:absolute. So that is tested, and if it's so, then it means Bootstrap has been loaded.

    So for any library, you need to choose a good example of something only that library can do, and style a hidden tag accordingly, then specify which css style to test, and what value you are expecting.

    For javscript it's even easier, because you can just test for the library itself, which usually has some well known variable added to the window or something to the DOM. So for jQuery it's window.jQuery, and for Bootstrap it can be tested as window.jQuery && window.jQuery.fn && window.jQuery.fn.modal and so on.

提交回复
热议问题