ibclee / one-piece Goto Github PK
View Code? Open in Web Editor NEWRecording the daily of development
Recording the daily of development
Math.random().toString().slice(-6)
调研typescript,基于老项目向typescript迁移, 参考:
ProtoTeam
Migrating from JavaScript
TypeScript-React-Conversion-Guide
遇到问题,配置后打包报错,升级webpack4应该可以解决,但是webpack4不向下兼容,尝试安装旧版本awesome-script-loader解决了
ERROR in ./src/base/index.js Module build failed: Error: It looks like you're using an old webpack version without hooks support. If you're using awesome-script-loader with React storybooks consider upgrading @storybook/react to at least version 4.0.0-alpha.3
之后又遇到antd的报错
ERROR in [at-loader] ./node_modules/antd/lib/form/Form.d.t Type 'keyof T' does not satisfy the constraint 'string'.
通过在tsconfig.js增加 "keyofStringsOnly": true
配置,
原因是TypeScript 2.9中添加的另外一项重要特性是在keyof和映射对象类型(mapped object type)中使用符号(symbol)和数字字面量。keyof操作符要比TypeScript推断唯一符号类型这一特性更早,因此keyof一直不能识别符号化的key。TypeScript 2.9改变了keyof的行为,能够识别唯一符号和数字字面量类型。因为这是一个破坏性的变更,所以可以通过--keyofStringsOnly标记切换回TypeScript 2.9版本之前的行为模式。
linux清理磁盘
df -h ,这个命令用于查看服务器空间,
du -h --max-depth=1,这个命令用于查看当前目录,哪个文件占用最大
du -sh *,这个命令也用于查看当前目录下各文件及文件夹占用大小
查看端口号是否被占用
netstat -anp|grep 80
Object.fromEntries( Object.entries(this.getPorts()).filter( ([, port]) => port.isDefaultPort(), ), );
export 和 export default
Linux查看某个端口号是否被占用: netstat -anp|grep 80
在一个vue项目中配置了单元测试,看了一些文档:Vue Test Utils
参考了vue官方的jest测试配置仓库:vue-test-utils-jest-example
执行test命令的时候遇到了一些es6语法编译的错误,搜索了一些解决办法,但是还没有解决
ERROR: 'import' and 'export' may appear only with 'sourceType: "module"' (3:0)
查看了axios文档,在项目中重新封装了一下
1.createProtal:render到一个组件里面去,实际改变的事网页上另一处的DOM结构
import React from "react";
import ReactDOM from "react-dom";
import { Button } from "antd";
export default class PortalSample extends React.PureComponent {
state = { visible: false };
renderButton() {
return (
<Button type="primary" onClick={() => this.setState({ visible: true })}>
打开对话框
</Button>
);
}
renderDialog() {
return (
<div className="portal-sample">
<div>这是一个对话框!</div>
<br />
<Button
type="primary"
onClick={() => this.setState({ visible: false })}
>
关闭对话框
</Button>
</div>
);
}
render() {
if (!this.state.visible) return this.renderButton();
return ReactDOM.createPortal(
this.renderDialog(),
document.getElementById("dialog-container"),
);
}
}
git log --since=2018-06-11 --until=2018-07-06 --author="libaochang" --pretty=tformat: --numstat | gawk '{ add += $1 ; subs += $2 ; loc += $1 - $2 } END { printf "added lines: %s removed lines : %s total lines: %s\n",add,subs,loc }' -
以一个名为 abc 的模块为例,TS源代码如下:
export function abc(s: string): string { return s.substr(0, 4); }
其声明文件有两种写法:
第一种,模块导出声明写法
declare interface funcAbcSign { (s: string): string } export declare let abc: funcAbcSign;
第二种,全局类型声明写法
declare module "abc" { interface funcAbcSign { (s: string): string } export let abc: funcAbcSign; }
如果要理解两者的区别,首先要理解其意义。模块导出声明写法 中,单从这个文件内容 看来是无法得知这些内容属于哪个模块的。所以必须将之与模块放在一起,作为内建声明文件, TypeScript 编译器才能得知其所属的模块。(或者放进 typings 的 external 目录)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.