在axios中传递Integer参数得到请求

时间:2018-01-15 09:47:47

标签: javascript vue.js axios

我试图在axios get请求中传递一个整数参数,但在浏览器中,键'this.look_data.value'的值不是字符串!..这就是我做的,

axios.get(window.App.targetURL+'/ccc/xxx?getint='+encodeURIComponent(this.look_data.value), window.App.configuration)           
                .then(response => {                  
                  this.value = (give.data);
                  this.values = true;                    
                })
                .catch(e => {
                  alert(e);
                })

1 个答案:

答案 0 :(得分:1)

尝试将其显式转换为字符串:

var d = new Date(this.look_data.value);

var options = {   
day: 'numeric', 
month: 'long', 
year: 'numeric'};

axios.get(window.App.targetURL+'/ccc/xxx?getint='+ encodeURIComponent(d.toLocaleDateString('en-US', options)), window.App.configuration)          
            .then(response => {                  
              this.value = (give.data);
              this.values = true;                    
            })
            .catch(e => {
              alert(e);
            })

如果这不起作用,请尝试在格式化日期转换它。有些图书馆会为您执行此操作或查看this post