I am trying to find a solution JavaScript methods call from anywhere in my project. I am using requirejs to load javascript library.
require.config({
paths: {
fastclick: "Vendors/fastclick/lib/fastclick.js",
},
//Mention the dependencies
shim: {
fastclick: {
exports: "FastClick"
},
Here I want to call first click methods like this way
FastClick.attach(tElement);
I do not want to use requirejs define('')
Here's a way to use it without define
:
require(["fastclick"], function () {
// The shimmed module leaks `FastClick` to the global space, so this will
// work.
FastClick.attach(tElement);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.