2016-04-20 13 views
1

ではありません:。togglePanel()がトリガー取得するときに

var $ = require('jquery'); 
var velocity = require('velocity-animate'); 

module.exports = function() { 

    function togglePanel() { 

     $('.trip-assist-search-panel__container').velocity({ 
      height: '0px' 
     },{ 
      duration: 400 
     }); 

    } 

    return { 
     togglePanel: togglePanel 
    }; 

}(); 

、次のエラーがスローされます:

Uncaught TypeError: $(...).velocity is not a function

通常はJQueryを必要とするライブラリの前にJQueryをロードしていることを確認することで解決します。しかし、私は..

var $ = require('jquery'); // first 
var velocity = require('velocity-animate'); // second 

だから何を与えるのですか?あなたが唯一のローカル$変数へのjQueryを割り当てた

Module Loader: Browserify
If you're using Velocity with jQuery, you must require jQuery before Velocity, and you must assign jQuery globally on the window object:

window.jQuery = window.$ = require("path/to/jquery-x.x.x.js"); 
require("path/to/velocity.js"); 
// Optional: If you're using the UI pack, require it after Velocity. (You don't need to assign it to a variable.) 
require("path/to/velocity.ui.js"); 
/* Your app code here. */ 
$("body").velocity({ opacity: 0.5 }); 

the documentationから

+0

jQueryをローカルvarに割り当てて、グローバルにではなく、なぜグローバル速度でしか使用できないのですか? なぜ私は速度の要件をローカル変数にも割り当てます。 – Seika85

答えて

関連する問題