Comenzando con requirejs
Hello World con dependencias anidadas
El siguiente ejemplo amplía Hello World
demostrando múltiples dependencias usando la función define()
.
Cree un nuevo archivo HTML llamado index.html
y pegue el siguiente contenido:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hello RequireJS</title>
<script type="text/javascript" src="http://requirejs.org/docs/release/2.3.2/minified/require.js"></script>
</head>
<body>
<!-- place content here --->
<script>
requirejs(["scripts/say"], function(say) {
console.log(say.hello("english"));
console.log(say.hello("spanish"));
console.log(say.hello("french"));
});
</script>
</body>