这个Browserify-shim设置不能与jquery-Moustache一起使用,为什么?

时间:2015-10-11 16:03:23

标签: javascript jquery browserify browserify-shim

以下设置可让jQuery插件mixitup完美运行。

"browser": {
        "mixitup": "./app/bower_components/mixitup/src/jquery.mixitup.js",
        "jquerymustache": "./app/bower_components/jquery-Mustache/src/jquery.mustache.js"
    },
    "browserify": {
        "transform": [
            "browserify-shim"
        ]
    },
    "browserify-shim": {
        "mixitup": {
            "exports": "mixitup",
            "depends": [
                "jquery:jQuery"
            ]
        },
        "jquerymustache": {
            "exports": "Jquerymustache",
            "depends": [
                "jquery:jQuery",
                "mustache:mustache"
            ]
        }
    },

但是,当我尝试将相同的约定应用于jquery-Mustache时,我无法获取模板:

 "browser": {
   "jquerymustache": "./app/bower_components/jquery-Mustache/src/jquery.mustache.js"
  }

"jquerymustache": {
      "exports": "Jquerymustache",
      "depends": [
        "jquery:jQuery",
        "mustache:mustache"
      ]
    }

我没有从终端收到错误,(这会证明package.json设置是犹太洁食)但我确实从控制台收到此错误:

http://embed.plnkr.co/vZI7aC/preview

指出这一点:

enter image description here

这是我的app.js文件,觉得这是最相关的信息:

var $ = jQuery = require('jquery');
var mixitup = require('mixitup');
var Jquerymustache = require('jquerymustache');
var mustache = require('mustache');

获取模板的功能。

function templateLoader(e) {
        var doc = document,
            event = EventUtility.getEvent(e),
            target = EventUtility.getTarget(event);
        $.Mustache.options.warnOnMissingTemplates = true;

        $.Mustache.load('templates/index.html')
            .fail(function() {
                $('#overlay').append('Failed to load templates from <code>templates.htm</code>');
            })
            .done(function() {
                var output = $('#overlay');
                $('body').mustache('templateID');
            });
    }

用于良好测量的文件路径,以证明函数中的路径是正确的:

enter image description here

0 个答案:

没有答案