Shim Twitter Bootstrap for RequireJS

后端 未结 4 2071
轻奢々
轻奢々 2020-12-04 10:32

The RequireJS docs say that to support older versions of IE, you need to configure enforceDefine: true.

So if you want to support Interne

4条回答
  •  隐瞒了意图╮
    2020-12-04 11:20

    According to the docs that error is thrown if "Script was part of a shim config that specified a global string property that can be checked for loading, and that check failed."

    To fix this you need to add exports value in the shim config so that RequireJS can check whether the script was succesfully loaded. In case of Bootstrap that's slightly tricky as Bootstrap doesn't 'export' a propert global variable only a bunch of jquery plugins, but you can use any of those plugins as an export value e.g. $.fn.popover:

    {
        paths: {
            "bootstrap": "../bootstrap",
            "jquery": "../jquery-1.8.2"
        },
        shim: {
            "bootstrap": {
              deps: ["jquery"],
              exports: "$.fn.popover"
            }
        },
        enforceDefine: true
    }
    

提交回复
热议问题