Git
和 linux
是一个做者github.com
coding.net
git add . // 添加 新增或者修改的文件
git commit -m "xxx" // 把修改的东西先提交到本地区域, "xxx" 修改的提示
git checkout xxx // 用于切换分支或恢复工做树文件。
git push // 推送到服务器
git pull // 从服务器拉下来代码
git branch // 分支
git checkout -b xxx // 新建一个分支
git checkout xx // 切换分支
git merge xxx // 用于从指定的commit(s)合并到当前分支的操做。
复制代码
git branch // 查看分支 master
git checkout -b dev // 建立分支 dev,并切换到dev 分支
git branch // 查看分支 master dev
git checkout master 切换到,aster
git merge dev // 合并分支
复制代码
不使用模块化的状况php
utils.js getFormatDate函数
底层工具a-util.js aGetFormatDate函数 使用getFormatDate
a.js aGetFormatDate
业务代码,层级引用关系// utils.js
function getFormatDate(date, type) {
// type = 1, 返回 2019-01-12 格式
// type = 2, 返回 2019年1月12日 格式
// ...
}
// a-util.js
function aGetFormatDate(date) {
// 要求返回 2019年1月12日 格式
return getFormatDate(date, 2)
}
// a.js
var dt = new Date()
console.log(aGetFormatDate(dt))
复制代码
使用模块化css
<script src="a.js"></script> 其余根据依赖自动引用
伪代码
// utils.js
export { // 暴露出去
getFormatDate: function (date, type) {
// type = 1, 返回 2019-01-12 格式
// type = 2, 返回 2019年1月12日 格式
// ...
}
}
// a-util.js
var getFormatDate = require('util.js') // 引用
export { // 暴露出去
aGetFormatDate: function (date) {
// 要求返回 2019年1月12日 格式
return getFormatDate(date, 2)
}
}
// a.js
var aGetFormatDate = require('a-util.js')
var dt = new Date()
console.log(aGetFormatDate(dt))
复制代码
AMD
require.js
define
函数require
函数Js
会自动 异步加载require.js
// util.js
define(function() {
return {
getFormatDate: function (date, type) {
if (type === 1) {
return '2019-02-14'
} else if (type === 2) {
return '2019年2月14日'
}
}
}
})
// 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
require(['./a.js'], function (a) {
var dt = new Date()
a.printDate(dt)
})
复制代码
nodejs
模块化规范, 如今被大量用前端, 缘由:html
npm
中获取npm
成本很是低CommonJS
不会异步加载JS, 而是同步一次性加载出来使用 CommonJs
前端
// util.js
module.exports = {
getFormatDate: function (date, type) {
if (type === 1) {
return '2019-02-14'
} else if (type === 2) {
return '2019年2月14日'
}
}
}
// a-util.js
var util = require('util.js') // 获取
module.exports = { // 推出
aGetFormatDate: function (date) {
return util.getFormatDate(date, 2)
}
}
// a.js
var aUtil = require('a-util.js')
module.exports = {
printDate: function (date) {
console.log(aUtil.aGetFormatDate(date))
}
}
复制代码
JS
, 使用 AMD
npm
以后建议使用 CommonJS
上线和回滚的基本流程node
linux基本命令linux
// 登陆
ssh name@serve
mkdir test // 建立文件夹
ls // 查看里面的文件
cd xxx // 到那个目录
pwd // 查看当前路径
cd .. // 返回升一级目录
rm -rf test // 删除文件夹 test
cp a.js a1.js // 拷贝文件
mv a1.js src/a1.js // 移动
rm a.js // 删除文件
vim b.js // 打开 vim, 并建立
cat a.js // 查看文件内容
head a.js // 查看文件前面的内容
tail a.js // 查看尾部的一点内容
head -n 1 a.js // 只看第一行的内容
tail -n 2 a.js // 后两行的内容
grep '2' a.js // 搜索
复制代码
题目git
url
到获得 html
的详细过程window.onload
和 DOMContentLoaded
的区别
DOM
渲染完便可执行, 此时图片, 视频还没加载完知识点 :github
加载资源的形式web
url
(或跳转页面) 加载 html
http://baidu.com
<scrript src="./a.js"></script>
加载一个资源的过程npm
DNS
服务器获得域名的 IP
地址IP
的机器发送 http
请求http
请求浏览器渲染页面的过程
HTML
结构生成 DOM Tree
css
生成 CSSOM
DOM
和 CSSOM
整合造成 RenderTree
RenderTree
开始渲染和展现<script>
时, 会执行并阻塞渲染CDN
让资源加载更快经过连接名称控制缓存
<script src="abc_1.js"></script>
只有内容改变的时候,连接名称才会改变
<script src="abc_2.js"></script>
复制代码
bootcdn https://www.bootcdn.cn/
复制代码
使用 SSR 后端渲染
缓存 DOM 查询
// 未缓存
var i
for (i=0; i < document.getElementsByTagName('p').length; i++) {
// todo
}
// 缓存了 DOM 查询
var pList = document.getElementsByTagName('p')
var i
for (i = 0; i < pList.length; i++) {
// todo
}
复制代码
var a = document.getElementById('list')
// 要插入 10个li标签
var frag = document.createDocumentFragment() // dom片断
var x, li
for () {
// ...
}
a.appendChild(frag)
复制代码
XSS 跨站请求攻击
<script>
预防 XSS
< 为 < > 为 >
XSRF 跨站请求伪造
xxx.com/pay?id=100
可是没有任何验证<img src="xxx.com/pay?id=100">
预防 XSRF