mirror of
https://github.com/YMFE/yapi.git
synced 2025-01-06 12:45:22 +08:00
opti: 返回结果样式
This commit is contained in:
parent
997a716164
commit
05bb97b91f
@ -138,8 +138,18 @@ export default class InterfaceTest extends Component {
|
|||||||
data: params,
|
data: params,
|
||||||
success: (res, header) => {
|
success: (res, header) => {
|
||||||
console.log(header)
|
console.log(header)
|
||||||
|
try {
|
||||||
|
res = JSON.parse(res);
|
||||||
|
} catch (e) {
|
||||||
|
null;
|
||||||
|
}
|
||||||
this.setState({res})
|
this.setState({res})
|
||||||
this.setState({ loading: false })
|
this.setState({ loading: false })
|
||||||
|
},
|
||||||
|
error: (err, header) => {
|
||||||
|
console.log(header)
|
||||||
|
this.setState({res: err || '请求失败'})
|
||||||
|
this.setState({ loading: false })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -285,7 +295,7 @@ export default class InterfaceTest extends Component {
|
|||||||
<div className="res-part">
|
<div className="res-part">
|
||||||
<div>
|
<div>
|
||||||
<TextArea
|
<TextArea
|
||||||
value={this.state.res ? JSON.stringify(this.state.res, 2) : ''}
|
value={typeof this.state.res === 'object' ? JSON.stringify(this.state.res, null, 2) : this.state.res.toString()}
|
||||||
style={{margin: 10}}
|
style={{margin: 10}}
|
||||||
autosize={{ minRows: 2, maxRows: 6 }}
|
autosize={{ minRows: 2, maxRows: 6 }}
|
||||||
></TextArea>
|
></TextArea>
|
||||||
|
Loading…
Reference in New Issue
Block a user