赞
踩
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
- </head>
- <body>
-
- <script>
- axios.interceptors.request.use(function (config) {
- // console.log(config);
- config.baseURL = 'http://localhost:9090/jstest';
- if (config.params)
- config.params.token = "xxxooo";
- else
- config.params = {token: "xxoo"};
- return config;
- })
-
- // 此种方式传参时,config 不带 params 属性
- axios.get("/news.php?a=1").then(function ({data}) {
- data.forEach(function (newsItem) {
-
- })
- });
-
- axios.get("/news.php", {
- params: {
- hot: 1
- }
- }).then(function ({data}) {
- data.forEach(function (newsItem) {
-
- })
- })
- </script>
- </body>
- </html>

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。