http.html
16.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>http 网络请求 | 买买买开发文档</title>
<meta name="description" content="买买买开发文档">
<link rel="preload" href="/assets/css/0.styles.72ea4e23.css" as="style"><link rel="preload" href="/assets/js/app.a6d4693a.js" as="script"><link rel="preload" href="/assets/js/2.0f93069c.js" as="script"><link rel="preload" href="/assets/js/13.c4d61fd4.js" as="script"><link rel="prefetch" href="/assets/js/10.ef686e6b.js"><link rel="prefetch" href="/assets/js/11.b9d66403.js"><link rel="prefetch" href="/assets/js/12.6e019225.js"><link rel="prefetch" href="/assets/js/14.94ce47cf.js"><link rel="prefetch" href="/assets/js/15.b0aed960.js"><link rel="prefetch" href="/assets/js/16.eaef222c.js"><link rel="prefetch" href="/assets/js/17.737b7002.js"><link rel="prefetch" href="/assets/js/3.09335edb.js"><link rel="prefetch" href="/assets/js/4.d1a4c2b6.js"><link rel="prefetch" href="/assets/js/5.811a1bdd.js"><link rel="prefetch" href="/assets/js/6.1745f7c4.js"><link rel="prefetch" href="/assets/js/7.bea9dafa.js"><link rel="prefetch" href="/assets/js/8.a4603644.js"><link rel="prefetch" href="/assets/js/9.e66f3185.js">
<link rel="stylesheet" href="/assets/css/0.styles.72ea4e23.css">
</head>
<body>
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="/logo.png" alt="买买买开发文档" class="logo"> <span class="site-name can-hide">买买买开发文档</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link">主页</a></div><div class="nav-item"><a href="/product/" class="nav-link">公司产品</a></div><div class="nav-item"><a href="/util/" class="nav-link">协作工具</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">工作团队</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/team/design/" class="nav-link">产品设计</a></li><li class="dropdown-item"><!----> <a href="/team/backend/" class="nav-link">服务端</a></li><li class="dropdown-item"><!----> <a href="/team/frontend/" class="nav-link router-link-active">前端</a></li><li class="dropdown-item"><!----> <a href="/team/android/" class="nav-link">安卓端</a></li><li class="dropdown-item"><!----> <a href="/team/ios/" class="nav-link">苹果端</a></li><li class="dropdown-item"><!----> <a href="/team/quality/" class="nav-link">测试组</a></li></ul></div></div><div class="nav-item"><a href="/guide/" class="nav-link">文档写作平台入门介绍</a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/" class="nav-link">主页</a></div><div class="nav-item"><a href="/product/" class="nav-link">公司产品</a></div><div class="nav-item"><a href="/util/" class="nav-link">协作工具</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">工作团队</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/team/design/" class="nav-link">产品设计</a></li><li class="dropdown-item"><!----> <a href="/team/backend/" class="nav-link">服务端</a></li><li class="dropdown-item"><!----> <a href="/team/frontend/" class="nav-link router-link-active">前端</a></li><li class="dropdown-item"><!----> <a href="/team/android/" class="nav-link">安卓端</a></li><li class="dropdown-item"><!----> <a href="/team/ios/" class="nav-link">苹果端</a></li><li class="dropdown-item"><!----> <a href="/team/quality/" class="nav-link">测试组</a></li></ul></div></div><div class="nav-item"><a href="/guide/" class="nav-link">文档写作平台入门介绍</a></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>http 网络请求</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/team/frontend/http.html#数据交互标准格式" class="sidebar-link">数据交互标准格式</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/team/frontend/http.html#数据请求封装使用说明" class="sidebar-link">数据请求封装使用说明</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/team/frontend/http.html#参数" class="sidebar-link">参数</a></li></ul></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="http-网络请求"><a href="#http-网络请求" aria-hidden="true" class="header-anchor">#</a> http 网络请求</h1> <h2 id="数据交互标准格式"><a href="#数据交互标准格式" aria-hidden="true" class="header-anchor">#</a> 数据交互标准格式</h2> <p>前后端数据交互标准格式</p> <div class="language-js extra-class"><pre class="language-js"><code><span class="token punctuation">{</span>
<span class="token comment">/**
* 请求结果
* -1:请求成功,但业务检查不通过
* 0:请求成功,数据正常返回
* 2:token 超时,主要用于用户登录超时、特定情况下主动清除用户登录状态
* 例如用户权限发生变化等场景
*/</span>
<span class="token string">"code"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token comment">/**
* 提示信息,错误时按UI规范显示错误信息,成功则返回操作成功
*/</span>
<span class="token string">"msg"</span><span class="token punctuation">:</span> <span class="token string">"姓名不能超过20个字符"</span><span class="token punctuation">,</span>
<span class="token comment">/**
* 请求返回结果 JSON类型
* 正常请求后返回的内容都应在data节点下生成
*/</span>
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
<span class="token comment">/** int、String、long等普通类型 */</span>
<span class="token string">"attr"</span><span class="token punctuation">:</span> value<span class="token punctuation">,</span>
<span class="token comment">/** 属性为JSON对象 */</span>
<span class="token string">"user"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
<span class="token string">"name"</span><span class="token punctuation">:</span> <span class="token string">"zhangsan"</span><span class="token punctuation">,</span>
<span class="token string">"age"</span><span class="token punctuation">:</span> <span class="token number">18</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token comment">/** 属性为一维数组,An为一维数组元素 */</span>
<span class="token string">"users"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token constant">A1</span><span class="token punctuation">,</span><span class="token constant">A2</span><span class="token punctuation">,</span><span class="token operator">...</span>An<span class="token punctuation">]</span>,
<span class="token comment">/** 属性为对象数组 */</span>
<span class="token string">"users"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span><span class="token constant">JSON</span>类型<span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span><span class="token constant">JSON</span>类型<span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token operator">...</span><span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">]</span>,
<span class="token comment">/**
* grid表格结果集格式 表单记录 JSON类型
*/</span>
<span class="token string">"gridResult"</span><span class="token punctuation">:</span><span class="token punctuation">{</span>
<span class="token comment">//当前页</span>
<span class="token string">"pageNumber"</span><span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span>
<span class="token comment">//总记录数</span>
<span class="token string">"totalRow"</span><span class="token punctuation">:</span> <span class="token number">3</span><span class="token punctuation">,</span>
<span class="token comment">//数据列表内容</span>
<span class="token string">"lists"</span><span class="token punctuation">:</span><span class="token punctuation">[</span>
<span class="token punctuation">{</span>
<span class="token string">"id"</span><span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span>
<span class="token string">"prop2"</span><span class="token punctuation">:</span> <span class="token string">""</span><span class="token punctuation">,</span>
<span class="token string">"status"</span><span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span>
<span class="token string">"remark"</span><span class="token punctuation">:</span> <span class="token string">""</span><span class="token punctuation">,</span>
<span class="token string">"prop1"</span><span class="token punctuation">:</span> <span class="token string">""</span><span class="token punctuation">,</span>
<span class="token string">"statusName"</span><span class="token punctuation">:</span> <span class="token string">"启用"</span><span class="token punctuation">,</span>
<span class="token string">"description"</span><span class="token punctuation">:</span> <span class="token string">"系统标题名称"</span><span class="token punctuation">,</span>
<span class="token string">"value"</span><span class="token punctuation">:</span> <span class="token string">"后台管理系统"</span><span class="token punctuation">,</span>
<span class="token string">"prop3"</span><span class="token punctuation">:</span> <span class="token string">""</span><span class="token punctuation">,</span>
<span class="token string">"code"</span><span class="token punctuation">:</span> <span class="token string">"SYSTEM_CAPTION"</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span>
<span class="token string">"id"</span><span class="token punctuation">:</span> <span class="token number">12860</span><span class="token punctuation">,</span>
<span class="token string">"prop2"</span><span class="token punctuation">:</span> <span class="token string">"2"</span><span class="token punctuation">,</span>
<span class="token string">"status"</span><span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span>
<span class="token string">"remark"</span><span class="token punctuation">:</span> <span class="token string">"2"</span><span class="token punctuation">,</span>
<span class="token string">"prop1"</span><span class="token punctuation">:</span> <span class="token string">"2"</span><span class="token punctuation">,</span>
<span class="token string">"statusName"</span><span class="token punctuation">:</span> <span class="token string">"启用"</span><span class="token punctuation">,</span>
<span class="token string">"description"</span><span class="token punctuation">:</span> <span class="token string">"定时任务开关"</span><span class="token punctuation">,</span>
<span class="token string">"value"</span><span class="token punctuation">:</span> <span class="token string">"0"</span><span class="token punctuation">,</span>
<span class="token string">"prop3"</span><span class="token punctuation">:</span> <span class="token string">"2"</span><span class="token punctuation">,</span>
<span class="token string">"code"</span><span class="token punctuation">:</span> <span class="token string">"SYSTEM_QUARTZ"</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span>
<span class="token string">"id"</span><span class="token punctuation">:</span> <span class="token number">12861</span><span class="token punctuation">,</span>
<span class="token string">"prop2"</span><span class="token punctuation">:</span> <span class="token string">"3"</span><span class="token punctuation">,</span>
<span class="token string">"status"</span><span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span>
<span class="token string">"remark"</span><span class="token punctuation">:</span> <span class="token string">"3"</span><span class="token punctuation">,</span>
<span class="token string">"prop1"</span><span class="token punctuation">:</span> <span class="token string">"3"</span><span class="token punctuation">,</span>
<span class="token string">"statusName"</span><span class="token punctuation">:</span> <span class="token string">"启用"</span><span class="token punctuation">,</span>
<span class="token string">"description"</span><span class="token punctuation">:</span> <span class="token string">"3"</span><span class="token punctuation">,</span>
<span class="token string">"value"</span><span class="token punctuation">:</span> <span class="token string">"3"</span><span class="token punctuation">,</span>
<span class="token string">"prop3"</span><span class="token punctuation">:</span> <span class="token string">"3"</span><span class="token punctuation">,</span>
<span class="token string">"code"</span><span class="token punctuation">:</span> <span class="token string">"3"</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span><span class="token operator">...</span><span class="token punctuation">}</span>
<span class="token punctuation">]</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre></div><h2 id="数据请求封装使用说明"><a href="#数据请求封装使用说明" aria-hidden="true" class="header-anchor">#</a> 数据请求封装使用说明</h2> <p>vue.$http()</p> <h3 id="参数"><a href="#参数" aria-hidden="true" class="header-anchor">#</a> 参数</h3> <ul><li>url</li></ul> <p>目标请求地址,地址分为两种类型:<code>当前域地址</code> 和 <code>其他域地址</code></p> <ul><li>data</li></ul> <p>提交的数据参数</p> <ul><li>options</li></ul> <p>配置参数,多数情况下不需要进行设置</p></div> <footer class="page-edit"><!----> <!----></footer> <!----> </main></div><div class="global-ui"></div></div>
<script src="/assets/js/app.a6d4693a.js" defer></script><script src="/assets/js/2.0f93069c.js" defer></script><script src="/assets/js/13.c4d61fd4.js" defer></script>
</body>
</html>