Skip to content

Commit

Permalink
fix: 优化文档
Browse files Browse the repository at this point in the history
  • Loading branch information
winixt committed Dec 13, 2023
1 parent d890ca0 commit fb52fae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 2 additions & 0 deletions docs/guide/upgrade3.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

1. 编译时的 [base](../reference/config/index.md/#base) 配置,移到了 [router.base](../reference/config/index.md/#router) 下。
2. [webpack-dev-server](https://github.com/webpack/webpack-dev-server)`v3.x` 升级到了 `v4.x`,如果遇到配置不兼容,可以查看[webpack-dev-server 3.x 升级 4.x](https://github.com/webpack/webpack-dev-server/blob/master/migration-v4.md)
3. [layout 插件](../reference/plugin/plugins/layout.md#_4-x-升级到-5-x) 有一些属性变更
3. [request 插件](../reference/plugin/plugins/request.md#_2-x-升级到-3-x) 有一些参数变更

## 继续使用 Webpack

Expand Down
19 changes: 11 additions & 8 deletions docs/reference/plugin/plugins/request.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ export default defineRuntimeConfig({
dataHandler(data, response) {
// 处理响应内容异常
if (data.code !== '0') {
if (data.code === '10000') {
if (data.code === '10000')
FMesseage.error('hello world');
}
if (data.code === '20000') {

if (data.code === '20000')
FMesseage.error('hello world');
}

throw new Error(response);
}
// 响应数据格式化
Expand All @@ -49,15 +49,18 @@ export default defineRuntimeConfig({
console.log(error.response.data);
console.log(error.response.status);
console.log(error.response.headers);
} else if (error.request) {
}
else if (error.request) {
// 请求已经成功发起,但没有收到响应
// `error.request` 在浏览器中是 XMLHttpRequest 的实例,
// 而在node.js中是 http.ClientRequest 的实例
console.log(error.request);
} else if (error.type) {
}
else if (error.type) {
// 插件异常
console.log(error.msg);
} else {
}
else {
// 发送请求时出了点问题
console.log('Error', error.message);
}
Expand Down Expand Up @@ -192,4 +195,4 @@ export default {
1. 删除 dataField 配置,通过 dataHandler 实现类似功能,详情看上文案例
2. errorHandler 改成了函数了,异常处理逻辑,查看上文案例
3. 废弃 base 参数,用 baseURL
4. 移除 skipErrorHandler 参数,直接传 errorHandler 可覆盖默认 errorHandler
4. 移除 skipErrorHandler 参数,目前还做了兼容,最好用 dataHandler 和 errorHandler 代替

0 comments on commit fb52fae

Please sign in to comment.