Skip to content

Instantly share code, notes, and snippets.

@vikingmute
Created January 24, 2020 01:09
Show Gist options
  • Save vikingmute/b056b5bd1a9d3048f23599f1103b216c to your computer and use it in GitHub Desktop.
Save vikingmute/b056b5bd1a9d3048f23599f1103b216c to your computer and use it in GitHub Desktop.
<!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