javascript - 在axios get请求中传递Integer参数

标签 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);
                })

最佳答案

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

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

关于javascript - 在axios get请求中传递Integer参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48260397/

相关文章:

javascript - 使用 AngularJS 创建导航的最佳选项是什么?

javascript - 用于抓取的服务器端脚本语言的替代方案

javascript - 重构不同作用域的变量

javascript - 在当前窗口中获取高亮文本并在弹出窗口中发送

javascript - 当没有 "next"照片可用时使用 Vue.js : disabling button on picture slideshow,

javascript - 在基于 react 类的组件中将 Prop 从父级传递给子级

javascript - 如何在没有 console.log 的情况下登录 Vue.js?

javascript - 从组件内部创建的 FullCalendar 对象访问 Vue 组件对象

javascript - axios 数据正在破坏请求