http.html 16.4 KB
<!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.4912dc4a.js" as="script"><link rel="preload" href="/assets/js/2.0265cc24.js" as="script"><link rel="preload" href="/assets/js/12.4bc67125.js" as="script"><link rel="prefetch" href="/assets/js/10.5d1faaf1.js"><link rel="prefetch" href="/assets/js/11.273f3b11.js"><link rel="prefetch" href="/assets/js/13.6e8dcadc.js"><link rel="prefetch" href="/assets/js/14.17b37ac4.js"><link rel="prefetch" href="/assets/js/15.7a94eebf.js"><link rel="prefetch" href="/assets/js/16.bcc1b39e.js"><link rel="prefetch" href="/assets/js/3.27460ccb.js"><link rel="prefetch" href="/assets/js/4.71c1aa61.js"><link rel="prefetch" href="/assets/js/5.9685e184.js"><link rel="prefetch" href="/assets/js/6.dc6acc37.js"><link rel="prefetch" href="/assets/js/7.be859890.js"><link rel="prefetch" href="/assets/js/8.bf5706ca.js"><link rel="prefetch" href="/assets/js/9.dca24dd5.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">&quot;code&quot;</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">&quot;msg&quot;</span><span class="token punctuation">:</span> <span class="token string">&quot;姓名不能超过20个字符&quot;</span><span class="token punctuation">,</span>
	<span class="token comment">/**
	 * 请求返回结果 JSON类型
	 * 正常请求后返回的内容都应在data节点下生成
	 */</span>
    <span class="token string">&quot;data&quot;</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>  
		<span class="token comment">/** int、String、long等普通类型 */</span>
		<span class="token string">&quot;attr&quot;</span><span class="token punctuation">:</span>value<span class="token punctuation">,</span> 
		 <span class="token comment">/**  属性为JSON对象  */</span> 
		<span class="token string">&quot;user&quot;</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
			<span class="token string">&quot;name&quot;</span><span class="token punctuation">:</span> <span class="token string">&quot;zhangsan&quot;</span><span class="token punctuation">,</span>
			<span class="token string">&quot;age&quot;</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">&quot;users&quot;</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">&quot;users&quot;</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">&quot;gridResult&quot;</span><span class="token punctuation">:</span><span class="token punctuation">{</span>
			<span class="token comment">//当前页</span>
			<span class="token string">&quot;pageNumber&quot;</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">&quot;totalRow&quot;</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">&quot;lists&quot;</span><span class="token punctuation">:</span><span class="token punctuation">[</span>
				<span class="token punctuation">{</span>
					<span class="token string">&quot;id&quot;</span><span class="token punctuation">:</span><span class="token number">1</span><span class="token punctuation">,</span>
					<span class="token string">&quot;prop2&quot;</span><span class="token punctuation">:</span><span class="token string">&quot;&quot;</span><span class="token punctuation">,</span>
					<span class="token string">&quot;status&quot;</span><span class="token punctuation">:</span><span class="token number">1</span><span class="token punctuation">,</span>
					<span class="token string">&quot;remark&quot;</span><span class="token punctuation">:</span><span class="token string">&quot;&quot;</span><span class="token punctuation">,</span>
					<span class="token string">&quot;prop1&quot;</span><span class="token punctuation">:</span><span class="token string">&quot;&quot;</span><span class="token punctuation">,</span>
					<span class="token string">&quot;statusName&quot;</span><span class="token punctuation">:</span><span class="token string">&quot;启用&quot;</span><span class="token punctuation">,</span>
					<span class="token string">&quot;description&quot;</span><span class="token punctuation">:</span><span class="token string">&quot;系统标题名称&quot;</span><span class="token punctuation">,</span>
					<span class="token string">&quot;value&quot;</span><span class="token punctuation">:</span><span class="token string">&quot;后台管理系统&quot;</span><span class="token punctuation">,</span>
					<span class="token string">&quot;prop3&quot;</span><span class="token punctuation">:</span><span class="token string">&quot;&quot;</span><span class="token punctuation">,</span>
					<span class="token string">&quot;code&quot;</span><span class="token punctuation">:</span><span class="token string">&quot;SYSTEM_CAPTION&quot;</span>
				<span class="token punctuation">}</span><span class="token punctuation">,</span>
				<span class="token punctuation">{</span>
					<span class="token string">&quot;id&quot;</span><span class="token punctuation">:</span><span class="token number">12860</span><span class="token punctuation">,</span>
					<span class="token string">&quot;prop2&quot;</span><span class="token punctuation">:</span><span class="token string">&quot;2&quot;</span><span class="token punctuation">,</span>
					<span class="token string">&quot;status&quot;</span><span class="token punctuation">:</span><span class="token number">1</span><span class="token punctuation">,</span>
					<span class="token string">&quot;remark&quot;</span><span class="token punctuation">:</span><span class="token string">&quot;2&quot;</span><span class="token punctuation">,</span>
					<span class="token string">&quot;prop1&quot;</span><span class="token punctuation">:</span><span class="token string">&quot;2&quot;</span><span class="token punctuation">,</span>
					<span class="token string">&quot;statusName&quot;</span><span class="token punctuation">:</span><span class="token string">&quot;启用&quot;</span><span class="token punctuation">,</span>
					<span class="token string">&quot;description&quot;</span><span class="token punctuation">:</span><span class="token string">&quot;定时任务开关&quot;</span><span class="token punctuation">,</span>
					<span class="token string">&quot;value&quot;</span><span class="token punctuation">:</span><span class="token string">&quot;0&quot;</span><span class="token punctuation">,</span>
					<span class="token string">&quot;prop3&quot;</span><span class="token punctuation">:</span><span class="token string">&quot;2&quot;</span><span class="token punctuation">,</span>
					<span class="token string">&quot;code&quot;</span><span class="token punctuation">:</span><span class="token string">&quot;SYSTEM_QUARTZ&quot;</span>
				<span class="token punctuation">}</span><span class="token punctuation">,</span>
				<span class="token punctuation">{</span>
					<span class="token string">&quot;id&quot;</span><span class="token punctuation">:</span><span class="token number">12861</span><span class="token punctuation">,</span>
					<span class="token string">&quot;prop2&quot;</span><span class="token punctuation">:</span><span class="token string">&quot;3&quot;</span><span class="token punctuation">,</span>
					<span class="token string">&quot;status&quot;</span><span class="token punctuation">:</span><span class="token number">1</span><span class="token punctuation">,</span>
					<span class="token string">&quot;remark&quot;</span><span class="token punctuation">:</span><span class="token string">&quot;3&quot;</span><span class="token punctuation">,</span>
					<span class="token string">&quot;prop1&quot;</span><span class="token punctuation">:</span><span class="token string">&quot;3&quot;</span><span class="token punctuation">,</span>
					<span class="token string">&quot;statusName&quot;</span><span class="token punctuation">:</span><span class="token string">&quot;启用&quot;</span><span class="token punctuation">,</span>
					<span class="token string">&quot;description&quot;</span><span class="token punctuation">:</span><span class="token string">&quot;3&quot;</span><span class="token punctuation">,</span>
					<span class="token string">&quot;value&quot;</span><span class="token punctuation">:</span><span class="token string">&quot;3&quot;</span><span class="token punctuation">,</span>
					<span class="token string">&quot;prop3&quot;</span><span class="token punctuation">:</span><span class="token string">&quot;3&quot;</span><span class="token punctuation">,</span>
					<span class="token string">&quot;code&quot;</span><span class="token punctuation">:</span><span class="token string">&quot;3&quot;</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.4912dc4a.js" defer></script><script src="/assets/js/2.0265cc24.js" defer></script><script src="/assets/js/12.4bc67125.js" defer></script>
  </body>
</html>