[英]Javascript method call in requirejs project
I am trying to find a solution JavaScript methods call from anywhere in my project. 我试图从我项目的任何地方找到解决方法JavaScript方法调用。 I am using requirejs to load javascript library.
我正在使用requirejs加载javascript库。
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('') 我不想使用requirejs define('')
Here's a way to use it without define
: 这是一种无需
define
即可使用的方法:
require(["fastclick"], function () {
// The shimmed module leaks `FastClick` to the global space, so this will
// work.
FastClick.attach(tElement);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.