javascript - 如何在Vue Js中通过axios调出查询

标签 javascript vue.js vuejs2 axios

我正在尝试使用如下网址调用查询搜索:

http://localhost/Stellar/public/api/companies?column=name&direction=desc&page=1

在 Vue Js 2.0 中尝试调用这样的东西:

axios.get('$(this.source)?column=$(this.query.column)&direction=$(this.query.direction)$page=$(this.query.page)')

它看起来像这样

http://localhost/Stellar/public/$(this.source)?column=$(this.query.column)&direction=$(this.query.direction)$page=$(this.query.page)

它没有转换数据。帮我解决这个问题。

谢谢。

最佳答案

当您在字符串中显式写出变量时,您并没有引用它们。

做这样的事情:

let source = this.source;
let column = this.query.column;
let direction = this.query.direction;
let page = this.query.page;

axios.get(source+"?column="+column+"&direction="+direction+"&page="+page);

关于javascript - 如何在Vue Js中通过axios调出查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44073376/

相关文章:

javascript - 如何使 bootstrap 表行可选择并将选定的行保留在过滤器上?

javascript - 单页应用程序开发的库/框架(截至 2013 年)

javascript - 在Vue中,template、render、VNode是什么关系?

php - 在同一台服务器(同一端口)上运行 Vue.js 和 Laravel

unit-testing - vuejs中的单元测试

php - Laravel 8 Jetstream Inertia 所有 Inertia 请求都必须收到有效的 Inertia 响应

vuejs2 - 我们如何使用 Bootstrap-Vue Carousel 显示多个项目?

javascript - 在*最后* CSS3 转换之后处理事件的可靠方法?

javascript - 始终将我的 jQuery 工具提示放置在父容器的中心

javascript - jQuery 实时时钟工作但浏览器卡住?