---
|
description:
|
globs: src/pilots/**/P*.js
|
alwaysApply: false
|
---
|
|
# 数据控制器
|
|
## 数据控制器空白模板
|
|
```js
|
/**
|
* PPageName - 页面名称
|
* @author 作者
|
*/
|
|
import Taro from '@tarojs/taro';
|
import { Pilot } from '@components/bases/Pilot';
|
import { $fetchCommon } from '@fetchers/FCommon';
|
|
export class PPageName extends Pilot {
|
|
$data() {
|
return {};
|
}
|
|
$mounted() {
|
this.onLoadDataResource();
|
}
|
|
// 加载用户详情
|
onLoadDataResource() {
|
Taro.showLoading();
|
$fetchCommon.getPageDetail()
|
.then(res => {
|
Taro.hideLoading();
|
if (!res) {
|
return;
|
}
|
// do something
|
});
|
}
|
|
}
|
```
|
|
说明:请求异常由请求层的基类自动处理,数据控制层跳过错误的逻辑,只处理请求成功的后续业务
|