2014-02-19 29 views
0

我加入Imager.js庫中的問題require.js負載,腳本工作完美無require.jsRequire.js和Imager.js未定義功能

Main.js

define([ 
     'jquery', 
     'bootstrap', 
     'imager', 
     'video' 
    ], 
    function($) { 
     'use strict'; 
     $('.dropdown-toggle').dropdown(); 
     $('#bvideo').magnificPopup({ 
      type: 'inline' 
     }); 
     videojs('video-cdve', { 
      'controls': true, 
      'autoplay': false, 
      'preload': 'auto', 
      'width': 'auto', 
      'height': 'auto' 
     }); 
     new Imager({ 
      availableWidths: { 
       320: '320x240', 
       640: 'large', 
       1024: 'large_x2', 
      } 
     }); 
    }); 

我得到這個錯誤

Uncaught ReferenceError: Imager is not defined

當我定義成像儀

define([ 
     'jquery', 
     'bootstrap', 
     'imager', 
     'video' 
    ], 
    function($, Imager) { 
     'use strict'; 
     $('.dropdown-toggle').dropdown(); 
     $('#bvideo').magnificPopup({ 
      type: 'inline' 
     }); 
     videojs('video-cdve', { 
      'controls': true, 
      'autoplay': false, 
      'preload': 'auto', 
      'width': 'auto', 
      'height': 'auto' 
     }); 
     new Imager({ 
      availableWidths: { 
       320: '320x240', 
       640: 'large', 
       1024: 'large_x2', 
      } 
     }); 
    }); 

現在我recive這個錯誤

Uncaught TypeError: undefined is not a function

請告訴我happend?我如何正確添加此庫與要求?

define([ 
     'jquery', 
     'bootstrap', 
     'imager', 
     'video' 
    ], 
    function($, Imager) { 

你要綁定Imager'bootstrap'模塊的價值:所以當你做到這一點

+0

'Imager'在傳遞參數時是第二個,但是在您的'define'數組中第三個導入它時 – ashley

回答

1

你的參數綁定到模塊以相同的順序,你怎麼在要求列出他們。更改順序:

define([ 
     'jquery', 
     'imager', 
     'bootstrap', 
     'video' 
    ], 
    function($, Imager) { 

我也算是你是否會需要像儀墊片,但我在自己code看到他們檢測到AMD的環境,並呼籲define

+0

我現在嘗試完美。感謝你的回答 – user3330198