I can not get the exports value When I import external links js file (main.js) as a dependency with requirejs,see the code.
console.log(m) //undefined
but I define the module "t" as a dependency in internal,it can get the return value,see the code.
console.log(n) //test
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script src="https://cdn.bootcss.com/require.js/2.3.3/require.min.js" ></script>
<script type="text/javascript">
define("t",["main"],function(m){
console.log(m) //undefined
return "test";
});
require(["t"],function(n){
console.log(n) //test
});
</script>
</body>
</html>
Here is the main.js:
define("m",[],function(){
return "test";
})
So what's the wrong with it?
t, you're not passing through a variable in place ofmin the function of the definition. - Obsidian Aget, if I change the module 'm' to 'main',it works.Does the module name must be the same with the file name?define("main",[],function(){ return "test"; })- user1841488