Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mould-vuecli3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lhfe
mould-vuecli3
Commits
d26b95fe
Commit
d26b95fe
authored
Sep 01, 2020
by
lipengcheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 重新提交
parent
cc196048
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
3 deletions
+41
-3
App.vue
src/App.vue
+3
-1
main.js
src/main.js
+3
-2
axios.js
src/plugins/axios.js
+35
-0
No files found.
src/App.vue
View file @
d26b95fe
...
...
@@ -14,7 +14,9 @@ export default {
return
this
.
$route
.
meta
.
layout
||
'default-layout'
}
},
async
created
()
{},
async
created
()
{
this
.
request
()
},
methods
:
{
async
request
()
{
let
result
=
await
this
.
$http
.
get
(
'/webapi/home/banner?type=1&category=18'
)
...
...
src/main.js
View file @
d26b95fe
...
...
@@ -4,7 +4,7 @@ import router from './router'
import
store
from
'./store'
import
'./registerServiceWorker'
import
'./assets/style/index.scss'
import
axios
from
'
axio
s'
import
axios
from
'
@/plugins/axios.j
s'
import
VueBus
from
'vue-bus'
import
VModal
from
'vue-js-modal'
import
moment
from
'@/plugins/moment.js'
...
...
@@ -13,11 +13,12 @@ import globalComponents from '@/components/global/index.js'
import
filters
from
'@/filters/index.js'
import
directives
from
'@/directives/index.js'
import
utils
from
'@/utils/index.js'
console
.
log
(
'axios:'
,
axios
)
// 全局注册layout组件
Vue
.
use
(
layoutComponents
)
// 注册自定义全局组件
Object
.
keys
(
globalComponents
).
forEach
((
compName
)
=>
Vue
.
component
(
compName
,
globalComponents
[
compName
]))
// 注册全局自定义filter
// 注
册全局自定义filter
Object
.
keys
(
filters
).
forEach
((
key
)
=>
Vue
.
filter
(
key
,
filters
[
key
]))
// 注册全局自定义directive
Object
.
keys
(
directives
).
forEach
((
key
)
=>
Vue
.
directive
(
key
,
directives
[
key
]))
...
...
src/plugins/axios.js
0 → 100644
View file @
d26b95fe
import
axios
from
'axios'
console
.
log
(
'axios:'
,
axios
)
/**
* 默认配置
*/
axios
.
defaults
.
baseURL
=
''
axios
.
defaults
.
headers
.
common
[
'a-laihua-defined-key'
]
=
'a customized value'
// 请求拦截
axios
.
interceptors
.
request
.
use
(
(
config
)
=>
{
// 在发送请求之前做些什么
// config.headers.common['cookie-id'] = cookieId
return
config
},
(
err
)
=>
{
// 对请求错误做些什么
Promise
.
reject
(
err
)
}
)
// 响应拦截
axios
.
interceptors
.
response
.
use
(
(
response
)
=>
{
// 对响应数据做点什么
return
response
},
function
(
error
)
{
// 对响应错误做点什么
return
Promise
.
reject
(
error
)
}
)
export
default
axios
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment