常用git命令
git add 修改
git checkout xxx 还原
git commit -m "xxx" 建到本地
git push origin master 远程仓库
git pull origin master 下载
git branch 分支
git checkout -b xxx/git checkout xxx 新建分支/切换分支
git merage xxx
git status 看状态
git diff 看不同
a.js aGetFormatDate
//util.js
function getFormaDate(date,type){
// type === 1 返回2019-02-17
// type === 2 返回2019年2月17日 格式
}
// a-util.js
function aGetFormatDate(date){
// 要求返回2019年2月17日
return getFormatDate(date,2)
}
// a.js
var dt = new Date();
console.log(aGetFormatDate(dt))
<!-- 使用 -->
<script src="util.js"></script>
<script type="a-util.js"></script>
<script src="a.js"></script>
2.a.js知道要引用a-util.js,但是他知道依赖于until.js
// util.js
export {
getFormatDate:function(date,type){
// type === 1 返回2017-06-15
//type === 2 返回2017年6月15日格式
}
}
// a-util.js
var getFormate = require(‘util.js‘);
export {
aGetFormatDate:function(date){
// 要求返回2019年2月17日格式
return getFormatDate(date,2)
}
}
// a.js
var aGetFormatDate = require(‘a-util.js‘);
var dt = new Date();
console.log(aGetFormatDate(dt))
<script src="a.js"></script>
其他的根据依赖关系自动引用require.js
使用`require.js
//util.js
define(function(){
return {
getFormatDate:function(date,type){
if(type === 1){
return `2019-02-17`
}
if(type === 2){
return `2019年2月17日`
}
}
}
})
// a-util.js
define([‘./util.js‘],function(util){
return {
aGetFormatDate:function(date){
return util.getFormatDate(date,2)
}
}
})
// a.js
define([‘./a-util.js‘],function(aUtil){
return {
printDate:function(date){
console.log(aUtil,aGetFormatDate(date))
}
}
})
// main.js
reuqire([‘./a.js‘],function(a){
var date = new Date();
a.printDate(date)
})
使用
<p>AMD test</p>
<script src="/require.min.js" data-main="./main.js"></script>
使用CommonJS
//util.js
module.export = {
getFormate:function(date,type){
if(type === 1){
return ‘2019-02-17‘
}
if(type === 2){
return ‘2019年2月17日‘
}
}
}
//a-util.js
var util = require(‘util.js‘);
module.export = {
aGetFormatDate:function(date){
return util.getFormatDate(date,2)
}
}
原文:https://www.cnblogs.com/DCL1314/p/10393133.html