Loading mustache using requirejs

后端 未结 4 2168
青春惊慌失措
青春惊慌失措 2021-02-19 18:58

I would like to load and use mustache by requirejs.

Maybe this question has already asked:
AMD Module Loading Error with Mustache using RequireJS

Anyway I am

4条回答
  •  隐瞒了意图╮
    2021-02-19 19:31

    You could probably also do in-line named define in the code that consumes mustache, or somewhere in "main.js" (saves the trouble of creating *-wrap file)

    define('mustache', ['libs/mustache/mustache'], function(){
        // Tell Require.js that this module returns a reference to Mustache
        return Mustache; // from global
    });
    require(
        ['jquery','underscore','backbone','mustache']
        , function($, _, BB, Mustache){
            // use them
        }
    )
    

提交回复
热议问题