i want to use a.js module's test();
my method: - a.js -
define(function (require, exports, module) {
function test(val) {
alert(val);
}
window.test = test;
}
have other methods ? sorry my english very pool, I hope you can understand, thx!
You shouldn't usually assign to globals from a RequireJS module (i.e. set properties on window
).
define(function() {
function test(val) {
alert(val);
}
return test;
}
<!-- import requirejs ... -->
<script>
// Use the return value from the "test" module.
require(["test"], function(testFn) {
testFn("hello");
});
</script>