Catching module loading errors and processing them

后端 未结 4 1280
名媛妹妹
名媛妹妹 2020-12-04 17:41

I am trying to load some content using require.js. If the content doesn\'t exist I\'d like to catch the error and notify the user.

In firebug I can see two errors:

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-04 18:21

    Did you try to override the requirejs.onError like shown here?

    It worked for me after setting catchError as true like this:

    require.config({catchError:true});
    

    before calling any define() or require() functions.

提交回复
热议问题