Created
January 24, 2020 01:09
-
-
Save vikingmute/b056b5bd1a9d3048f23599f1103b216c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Backbone.js Todos</title> | |
<link rel="stylesheet" href="todos.css"/> | |
</head> | |
<body> | |
<script src="../../test/vendor/json2.js"></script> | |
<script src="../../test/vendor/jquery.js"></script> | |
<script src="../../test/vendor/underscore.js"></script> | |
<script src="../../backbone.js"></script> | |
<script src="../backbone.localStorage.js"></script> | |
<script src="todos.js"></script> | |
</body> | |
<!-- (...) --> | |
</html> | |
var myRevealingModule = (function () { | |
var privateVar = "Ben Cherry", | |
publicVar = "Hey there!"; | |
function privateFunction() { | |
console.log( "Name:" + privateVar ); | |
} | |
function publicSetName( strName ) { | |
privateVar = strName; | |
} | |
function publicGetName() { | |
privateFunction(); | |
} | |
// Reveal public pointers to | |
// private functions and properties | |
return { | |
setName: publicSetName, | |
greeting: publicVar, | |
getName: publicGetName | |
}; | |
})(); | |
myRevealingModule.setName( "Paul Kinlan" ); | |
// common.js | |
const bar = require('./bar'); | |
// 模块产出 | |
module.exports = function () { | |
// ... | |
}; | |
// AMD | |
define(function (require) { | |
// 通过相对路径获得依赖模块 | |
const bar = require('./bar'); | |
// 模块产出 | |
return function () { | |
// ... | |
}; | |
}); | |
//es6 module | |
// 通过相对路径获得依赖模块 | |
import bar from './bar'; | |
// 模块产出 | |
export default function () { | |
// ... | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment