ChampYin's Blog

自律是真正的自由


  • Home

  • Tags

  • Archives

  • About

  • Categories

  • Search

windows下模拟域名

Posted on 2018-10-05 | In 操作系统 | Visitors:
Words : 48 | Reading ≈ 1 min

在 c盘下 windows/system32/drivers/etc/host 文件内,可以添加设置域名,将本地起的服务模拟成域名形式,便于相关前端测试,比如测试跨域。

快速使用express搭建服务

Posted on 2018-10-05 | In 前端技术 | Visitors:
Words : 367 | Reading ≈ 1 min

使用 express 搭建最简单的服务。需要有 node 环境。

1. 安装 express

1
npm install express

2. 编写最简单的服务

  • 新建 server.js 文件
  • 打开 server.js 文件,写入:
Read more »

跨域

Posted on 2018-10-05 | In 前端技术 | Visitors:
Words : 96 | Reading ≈ 1 min

浏览器同源策略:
请求的地址与平台的协议、域名、端口号,都一致,称为 同域。
只要有一个不一样,就称为 跨域。

cookie、 Localstorage 不能跨域;
DOM元素也有同源策略(iframe);
ajax 也不支持跨域。

可以跨域的 html 标签:
link、 img、 script

如何实现跨域:

  1. jsonp
  2. cors
  3. postMessage
  4. document.domain
  5. window.name
  6. location.hash
  7. http-proxy
  8. ngix
  9. WebSocket

如何使用gitbook发布自己的书籍

Posted on 2018-10-05 | In 工具 , GitBook | Visitors:
Words : 1.2k | Reading ≈ 4 min

利用开源项目 gitbook,自己写本书吧~

前言:gitbook 平台在今年的4月9日发布了新的版本v2。新的版本官网已经变成 www.gitbook.com (旧的地址为 legacy.gitbook.com )。新旧版本有很多的不一样,网上很多资料都是针对旧版。 比如新版不再支持把每本书作为一个 Git Repository 来进行版本管理。(以前是可以针对每本书从本地 git push 到 gitbook 的),这点也是坑了我很久(坑一个强迫症重度患者的结果就是,不扒出被坑的根本原因誓不罢休)。更多 v2 的重大改变可以看 这里。

以下的所有操作都是针对新版的 gitbook。

Read more »

如何给github项目建立自己的主页

Posted on 2018-10-05 | In 工具 , GitHub | Visitors:
Words : 261 | Reading ≈ 1 min

想给 github 项目发布一个可访问的地址,网上的资料虽然多,但是乱。总的来讲,分为两种方法:一种是通过 github 的 htmlpreview 插件来展示。另一种就是通过 github pages 来展示。关于 github pages 网上很多人对它有误解,认为一定要先创建 username.github.io 这个 repository 才可以,其实并不需要;还有人认为一定要把要展示的静态资源放在项目的 gh-pages 分支上才可以,其实也不用。

总结一下我利用 github pages 给自己的项目创建主页的方法。

步骤如下:

Read more »

如何在mac上查看隐藏文件

Posted on 2018-10-05 | In 操作系统 | Visitors:
Words : 17 | Reading ≈ 1 min

在 Finder 里,按 Cmd + Shift + . 即可切换隐藏文件的显隐。

进阶(三):博客域名升级

Posted on 2018-09-29 | In 博客搭建 | Visitors:
Words : 137 | Reading ≈ 1 min
  1. 购买域名,我是在阿里云上购买的,.com域名。
    • 先查询你想的域名是否已经被注册,如果有那就要另想一个了。
    • 选择购买时长,一次买长一点的好像比一年一年买要划得来,而且也不容易被别人抢注。
    • 然后购买,购买前要实名认证。
  2. 配置DNS,添加记录,将github page域名添加进去。
  3. github上配置custom domain,设置为新购买的域名。
  4. hexo source里添加CNAME文件,内容为新购买的域名。

利用json-server+faker模拟API服务和数据

Posted on 2018-09-26 | In 前端技术 | Visitors:
Words : 0 | Reading ≈ 1 min

javascript中的Date

Posted on 2018-09-26 | In 前端技术 | Visitors:
Words : 211 | Reading ≈ 1 min

chrome下

结论:

1. 日期有前置0,则会解析为 UTC 时间,没有前置0,则会解析为本地时间。

例如
new Date('2018-09-26').getTime() 获取的是距离1970年1月1日0点UTC时间。
new Date('2018-9-26').getTime() 获取的是距离1970年1月1日0点本地时间。

2. Date.now()、 +new Date()、 new Date().getTime(), 获取的都是距离1970年1月1日0点本地时间。

检验依据:Date.UTC() 该方法使用的是UTC时间。而 Date.UTC(2018, 8, 26) 跟 Date.now()、 +new Date()、 new Date().getTime() 获得的值相差8个小时。

ie下

Read more »

win10下中文输入法简繁切换快捷键

Posted on 2018-09-26 | In 操作系统 | Visitors:
Words : 11 | Reading ≈ 1 min

在中文输入法下,按 ctr+shift+f 。

1…789…11
ChampYin

ChampYin

Life doesn't get easier, you just get stronger.

110 posts
22 categories
115 tags
© 2025 ChampYin | 109.1k
Powered by Hexo
| UV | PV
浙ICP备2020044347号-1