【问题标题】:Multiple tests with YepNope.js?使用 YepNope.js 进行多项测试?
【发布时间】:2014-03-21 17:05:02
【问题描述】:

我正在使用 yepnope 根据测试有条件地加载脚本 (duh),但我遇到了一个问题,我想测试多个条件,并根据所述结果加载多个 polyfill。

例如,例如:

 yepnope([{
     test: test1 || test2,
     nope: ['poly1.js', 'poly2.js'],
     load: ['default.js']
}]);

不幸的是,最终用户可能只需要 poly1 而不需要 poly2,在上述情况下,即使只有一个测试失败,也会加载两者。

我想我要问的是有没有一种方法可以用 yepnope 加载只需要的脚本,而不会疯狂嵌套/大量使用完整的函数?与加载多个脚本相反,即使只有一个测试失败。

【问题讨论】:

    标签: javascript yepnope


    【解决方案1】:

    只需将整个内容复制到其他功能测试中,例如:

    yepnope({
        test: Modernizr.csstransitions,
        yep: 'transitions_js.js',
        nope: 'no_transitions_js.js'
    });
    yepnope({
        test: Modernizr.svg,
        nope: 'no_svg.css'
    });
    

    希望现在回答这个问题还为时不晚 :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-19
      • 2023-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多