I have a project with

  1. backbonejs
  2. requirejs

and i want to include iscroll v5 but i don't know how i can load it and init it with requirejs...

I already tried to find a solution in any fork of the project but so far i didn't find anything.

I'm a newbie in JS so i need some help with this, anyone can post an example or provide a simple demo?

有帮助吗?

解决方案

You can include the path of the iscroll plugin in the configuration file where you declare the dependencies and paths for other files.

require.config({
    locale: 'en_us',

    baseUrl: 'baseUrl',
    paths: {
        // Paths of the libraries being used
        'Iscroll' : 'relative path to the file',
        ......
        ......  Other files
    },
    shim : { // If the library does not support AMD
        'Iscroll': {
             exports: 'Iscroll'
         },
    }
});

Now if you want to use that in a specfic Module, just include it

define(['Iscroll', other args], function(Iscroll, other args) {

});
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top