【问题标题】:Adding jQuery Mobile to a Yeoman Backbone project将 jQuery Mobile 添加到 Yeoman Backbone 项目
【发布时间】:2014-02-28 19:00:10
【问题描述】:

我是 Yeoman 的新手,我正在使用官方 Backbone 生成器设置一个新项目。我已经使用以下命令添加了 jQuery Mobile:

bower install -save jquery-mobile

当我运行应用程序时,require.js 报告我所有的 jquery-mobile 脚本都丢失了。我已经阅读了关于 herehere 的帖子。我一定是少了一个步骤,或者我的 main.js 设置错误。

这是我的 main.js 的相关部分:

require.config({
  shim: {
      <...>
      jquerymobileconfig: {
        deps: [
            'jquery'
        ]
      },
      jquerymobile: {
        deps: [
          'jquery',
          'jquerymobileconfig'
        ]
      }
  },
  paths: {
    jquery: '../bower_components/jquery/jquery',
    jquerymobileconfig: 'jqmconfig',
    jquerymobile: '../bower_components/jquery-mobile/js/jquery.mobile',
    backbone: '../bower_components/backbone/backbone',
    underscore: '../bower_components/underscore/underscore'
  }
});

require([
  'jquery', 'backbone', 'jquerymobile'
], function ($, Backbone) {
  Backbone.history.start();
});

【问题讨论】:

    标签: jquery-mobile backbone.js requirejs yeoman


    【解决方案1】:

    我找到了我的问题here 的答案。不要安装 bower jquery-mobile 项目,而是安装:

    bower install -save jquery-mobile-bower
    

    这是用于 bower/Yeoman 项目的 jquery-mobile 的现成版本。然后在 main.js 中引用 jquery mobile 为:

    jquerymobile: '../bower_components/jquery-mobile-bower/js/jquery.mobile-1.4.1.min',
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-26
      相关资源
      最近更新 更多