소스 검색

修改post请求conten-Type

Shan9312 1 년 전
부모
커밋
b308f90834
3개의 변경된 파일9개의 추가작업 그리고 3개의 파일을 삭제
  1. BIN
      dist-tmr-20250103-正式包.zip
  2. 3 2
      src/utils/request.js
  3. 6 1
      src/views/formulationPlan/pushMaterialPlan/index.vue

BIN
dist-tmr-20250103-正式包.zip


+ 3 - 2
src/utils/request.js

@@ -33,11 +33,12 @@ service.interceptors.request.use(
     // do something before request is sent
     // config.headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'  //此处是增加的代码,设置请求头的类型
     // debugger
+    console.log(process.env.VUE_APP_BASE_API,'process.env.VUE_APP_BASE_API')
     if (process.env.VUE_APP_BASE_API !== '/dev-api') {
-      config.headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'
+      config.headers['Content-Type'] = 'application/json;charset=UTF-8'
       config.withCredentials = false
     }
-    // console.log(config,'config')
+    console.log(config,'config')
 
     if (store.getters.token) {
       // let each request carry token

+ 6 - 1
src/views/formulationPlan/pushMaterialPlan/index.vue

@@ -182,7 +182,12 @@ export default {
           pastureid: Cookies.get('pastureid'),eqtype:'1'
         }
       }
-      postJson(url,data).then(response => {
+      postJson(url, data, {
+         headers: {
+          'Content-Type': 'application/json',
+            type:'true'
+         }
+      }).then(response => {
         if (response.data.list !== null) {
           this.tmrList = response.data.list
         } else {