读完了《远见》这本书,收益匪浅。相信以后自己遇到职业问题的时候,可以回过头来寻求答案。
以下是记录的Xmind笔记。
对应的xmind下载地址:
把《You dont’t know Javascript》上篇看了一些,第一部分作用域和闭包看完了,第二部分除了第4、6章,其他都看完了。
本篇文章想通过几个例子,深入到作用域、变量提升、this的原理。
我们都知道变量会提升,那么这些面试题你能保证都做对吗?
先看一下这些题,由简到难:
1 | // eg1 |
答案:
typescript
: dnpm i --save-dev typescript
tsconfig.json
文件,如下(以后补充):在webpack
中添加ts配置,先安装ts-loader
,dnpm i --save-dev ts-loader
1 | rules: [ |
其中appendTsSuffixTo: [/\.vue$/]
是为了能够使用SFC单文件组件
main.js
改为main.ts
, app.vue
的script块要改成lang="ts"
使用Vue.use
报错Property 'use' does not exist on type 'typeof Vue'
这是因为tsconfig.json配置没有写对,正确的配置:
1 | { |
报错
vue.esm.js:5109 Uncaught TypeError: Cannot read property ‘install’ of undefined
at Function.Vue.use (vue.esm.js:5109)
at Object../client/main.ts (main.ts:13)
tsconfig加上配置: "esModuleInterop": true
参考:
https://github.com/Microsoft/TypeScript-Vue-Starter#typescript-vue-starter
tsconfig.json配置说明:
“moduleResolution”: “node” // https://www.typescriptlang.org/docs/handbook/module-resolution.html
使用echarts的坑:
下载B站视频,并转成音频
第一步,终端执行命令brew install you-get
安装you-get
第二步,执行命令you-get url
,如:you-get https://www.bilibili.com/video/av2573905/\?p\=3
,就可以将视频下载到当前目录
第三步,通过quicktime player打开下载的视频,保存为mp4(选择仅音频)
如果下载的视频是flv格式,quicktime player无法打开,则需要先下载quicktime插件Perian
,下载地址perian,安装后,就可以打开flv格式文件,然后再执行第三步。
如果flv文件仍然打不开,就需要借助其他转换工具,比如:https://www.xunjieshipin.com/video/flv2mp4
现有的:
gitstats 安装
比较好的可视化网站:https://gitstats.report/
github: https://github.com/arjun27/gitstats
它实现的功能有:
项目维度:
commits维度:只能获取指定项目的commits
我要实现的功能及步骤:
如何鉴权?
gitlab提供三种方式进行鉴权,鉴权方式
方案一:使用private token
优点:实现简单
缺点:
方案二:使用oauth2 token
Callback URL
,会生成Application ID
、Secret
https://gitlab.example.com/oauth/authorize?client_id=APP_ID&redirect_uri=REDIRECT_URI&response_type=token&state=YOUR_UNIQUE_STATE_HASH
可以得到一个code,这里我应该使用https://git.xiaojukeji.com/oauth/authorize?client_id=APP_ID&redirect_uri=REDIRECT_URI&response_type=token
,state可以不加。APP_ID就是Application ID
post
请求至https://gitlab.example/com/oauth/token
,参数是{
"client_id": "APP_ID",
"client_secret": "APP_SECRET",
"code": "RETURN_CODE",
"grant_type": "authorization_code",
"redirect_uri": "REDIRECT_URI"
}
access_token
是我们想要的:{
"access_token": "1f0af717251950dbd4d73154fdf0a474a5c5119adad999683f5b450c460726aa",
"token_type": "bearer",
"expires_in": 7200
}
access_token
后,就可以正常发起请求了过程:
问题:是否会过期?
现象:
问题抽象:
原理: