不使用jQuery在Backbonejs中刷卡

宏观垫

在主干应用程序中遇到这种滑动功能问题当我尝试将Hammer.js添加到HEAD时出现错误:

Uncaught TypeError: Object [object Array] has no method 'addEventListener'  hammer.min.js:7

您是否知道除Hammer.js之外的其他JavaScript,并且不依赖于jQuery在骨干网中正常工作?

我的头

<head>
<meta charset="utf-8">
<title>Backbone App</title>
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1">
<script data-main="js/main" src="js/libs/require/require.js"></script>
<script src="js/libs/utils.js"></script>
<script src="js/libs/hammer/swipeout.js"></script>
</head>

我的main.js

require.config({
  paths: {
    'jquery': 'libs/jquery/jquery.min',
    'underscore': 'libs/lodash/lodash.min',
    'backbone': 'libs/backbone/backbone.min',
    'templates': '../templates',
    'hammer': 'libs/hammer/hammer.min'
  },
    shim : {

    }
});
require(['jquery'], function($) {
    return {};
});

require([
  // Load our app module and pass it to our definition function
  'app'

], function(App){
  // The "app" dependency is passed in as "App"
  // Again, the other dependencies passed in are not "AMD" therefore don't pass a parameter to this function
  App.initialize();
});

非常感谢!

曼尼什(Manish Mulimani)

我使用SwipeOut,Hammer,Jquery和Backbone创建了一个示例Web应用程序。我已经将代码提交github仓库必须更改Swipeout以提供它的AMD版本,因此请使用此swipeout.js文件。

与其从index.html加载锤和刷卡,不如从任何javascript文件中异步加载它们。进行以下更改:

  1. 从index.html移除swipeout脚本标签
  2. 如下所示更新main.js。由于swipe.js,Backbone,下划线和jquery是非AMD文件,因此您需要定义填充程序配置。请注意,Hammer是AMD模块,因此不需要垫片配置。为了演示,我将锤子和刷卡文件加载到应用程序模块中。
require.config({
  paths: {
    'jquery': 'libs/jquery/jquery.min',
    'underscore': 'libs/lodash/lodash.min',
    'backbone': 'libs/backbone/backbone.min',
    'templates': '../templates',
    'hammer': 'libs/hammer/hammer.min',
    'swipeout': 'libs/hammer/swipeout'
  },
   shim : {
    'backbone': {
        deps: ['underscore', 'jquery'],
        exports: 'Backbone'
    },
    'underscore': {
        exports: '_'
    },
    'jquery': {
        exports: '$'
    },
    'swipeout': {
       exports: 'SwipeOut'
    }
  }
});

require([
  // Load our app module and pass it to our definition function
  'app',
  'hammer',
  'swipeout',
  'jquery'

], function(App,Hammer,Swipeout, $){
  // The "app" dependency is passed in as "App"
  // Again, the other dependencies passed in are not "AMD" therefore don't pass a parameter to this function
  App.initialize();
});

让我知道是否可以解决问题。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

不使用jQuery在Backbonejs中刷卡

来自分类Dev

在jQuery中不使用

来自分类Dev

jQuery的移动刷卡延迟?

来自分类Dev

在jQuery中屏蔽输入-不使用库

来自分类Dev

在Jquery中替换数组而不使用循环

来自分类Dev

在UICollectionView中检测刷卡

来自分类Dev

使用javascript在标签中应用样式(不使用jQuery)

来自分类Dev

不使用jQuery时ng-include中的AngularJS错误

来自分类Dev

jQuery:从数组中删除“”值,而不使用每个

来自分类Dev

试图在JavaScript中更改背景img(不使用jQuery)

来自分类Dev

event.preventDefault-在Firefox中,不使用jquery

来自分类Dev

如何在不使用 Jquery 的 Javascript 中修改此 css?

来自分类Dev

如何使用BackboneJS禁止PAN号码中的特殊字符

来自分类Dev

在Xamarin(Visual Studio)中为Android刷卡,例如在地图/新闻中使用Google卡

来自分类Dev

不使用jQuery更改文本

来自分类Dev

CSS不使用jQuery更改

来自分类Dev

jQuery Mobile / Phonegap面板嵌套刷卡

来自分类Dev

在Webview中刷卡刷新太早了

来自分类Dev

如何在Viewpager中启用整页刷卡?

来自分类Dev

在android中刷卡时翻转图片

来自分类Dev

在Webview中刷卡刷新太早了

来自分类Dev

使用UICollectionView和UICollectionViewCells创建刷卡堆栈?

来自分类Dev

在不使用jquery的情况下使用Javascript在vbscript填充的下拉列表中检索选定的值

来自分类Dev

在css或html中悬停而不使用JQuery时,如何使用鼠标指针在图像上移动文本

来自分类Dev

通过验证的引导模型(弹出框),使用简单的方法或在Codeigniter中不使用jquery

来自分类Dev

如何使用 Ajax 但不使用 jQuery 在单独的文件中调用 PHP 函数?

来自分类Dev

在SQL查询中不使用

来自分类Dev

在querySelector中不使用空格

来自分类Dev

使用JavaScript淡入图像(不使用JQuery!)

Related 相关文章

  1. 1

    不使用jQuery在Backbonejs中刷卡

  2. 2

    在jQuery中不使用

  3. 3

    jQuery的移动刷卡延迟?

  4. 4

    在jQuery中屏蔽输入-不使用库

  5. 5

    在Jquery中替换数组而不使用循环

  6. 6

    在UICollectionView中检测刷卡

  7. 7

    使用javascript在标签中应用样式(不使用jQuery)

  8. 8

    不使用jQuery时ng-include中的AngularJS错误

  9. 9

    jQuery:从数组中删除“”值,而不使用每个

  10. 10

    试图在JavaScript中更改背景img(不使用jQuery)

  11. 11

    event.preventDefault-在Firefox中,不使用jquery

  12. 12

    如何在不使用 Jquery 的 Javascript 中修改此 css?

  13. 13

    如何使用BackboneJS禁止PAN号码中的特殊字符

  14. 14

    在Xamarin(Visual Studio)中为Android刷卡,例如在地图/新闻中使用Google卡

  15. 15

    不使用jQuery更改文本

  16. 16

    CSS不使用jQuery更改

  17. 17

    jQuery Mobile / Phonegap面板嵌套刷卡

  18. 18

    在Webview中刷卡刷新太早了

  19. 19

    如何在Viewpager中启用整页刷卡?

  20. 20

    在android中刷卡时翻转图片

  21. 21

    在Webview中刷卡刷新太早了

  22. 22

    使用UICollectionView和UICollectionViewCells创建刷卡堆栈?

  23. 23

    在不使用jquery的情况下使用Javascript在vbscript填充的下拉列表中检索选定的值

  24. 24

    在css或html中悬停而不使用JQuery时,如何使用鼠标指针在图像上移动文本

  25. 25

    通过验证的引导模型(弹出框),使用简单的方法或在Codeigniter中不使用jquery

  26. 26

    如何使用 Ajax 但不使用 jQuery 在单独的文件中调用 PHP 函数?

  27. 27

    在SQL查询中不使用

  28. 28

    在querySelector中不使用空格

  29. 29

    使用JavaScript淡入图像(不使用JQuery!)

热门标签

归档