处理超大查询参数的文件下载

通常我们会使用 <a>download 属性来实现文件下载,例如

1
<a download href="abc.pdf">下载</a>

如果需要传递参数给下载接口,并且参数非常大以至于无法编码到 url 上,又改如何处理呢?

Read More


为什么在 componentDidMount 里调用 this.setState 浏览器只会绘制一次

偶然注意到 React 文档中的一句话

You may call setState() immediately in componentDidMount(). It will trigger an extra rendering, but it will happen before the browser updates the screen. This guarantees that even though the render() will be called twice in this case, the user won’t see the intermediate state.

对 “user won’t see the intermediate state” 有些难以相信。可以确定的是,由于“额外的渲染”,dom 的确发生了变更。为何 dom 发生了变更,浏览器却只绘制了一次呢?

Read More



前端微服务化在才云的实践

compass 是才云的核心产品,包含了集群资源管理、应用管理、运维管理和告警等一系列功能。微服务作为 compass 的服务目标之一,也是才云构建自身产品的一种“本能”的思考方式。随着产品功能的不断丰富,技术栈的不断扩充,compass 的前端 compass-web 面临着一个挑战:如何将越来越大的单体应用微服务化。

Read More


从 REST 到 GraphQL:ID 设计

现在 GraphQL 非常流行,不过要将运行在 REST 上的产品迁移到 GraphQL 并不太容易。不用 GraphQL 重写,而是在现有的 REST 上加一层 GraphQL 是比较科学的方法。

Read More



defer 脚本的执行顺序

以下代码的输出顺序是什么?顺序是稳定的吗?

1
2
3
4
5
6
<html>
<body>
<script defer async src="defer.js"></script>
<script src="index.js"></script>
</body>
</html>
1
2
// defer.js
console.log(document.readyState, 'defer.js');
1
2
// index.js
console.log(document.readyState, 'index.js');

Read More