相同的VueJS代码在两种不同的环境中的行为不同

时间:2019-02-01 10:04:48

标签: javascript vue.js

我在VueJS上有一个项目,其中前端(JS)向API发出请求,以JSON获取数据,并根据接收到的数据构建自己的逻辑。

请求外观如下:

axios
   .get(`/api/v1/resource/${this.$route.params.id}`, {
      headers: {
         "Content-Type": "application/json",
         "Authorization": localStorage.getItem('token')
      },
   })

根据JS所在的环境,响应数据具有不同的类型。

在本地环境中:

{
    "id":128, (Integer)
    "status":7001,  (Integer)
    "title":"2638-01-19_buh@ztc.com" (String)
    "is_bookmark":false (Bool)
}

生产中:

{
    "id":"128", (String)
    "status":"7001",  (String)
    "title":"2638-01-19_buh@ztc.com" (String)
    "is_bookmark":"false"   (String)
}

API数据发送如下:

{
    "id":128, (Integer)
    "status":7001,  (Integer)
    "title":"2638-01-19_buh@ztc.com" (String)
    "is_bookmark":false (Bool)
}

我试图在本地编译Vue并推送到生产app.js文件,没有结果。

任何想法或暗示可能是什么问题?

0 个答案:

没有答案
相关问题