【问题标题】:Pass date inside the $axios $get url在 $axios $get url 中传递日期
【发布时间】:2020-10-24 18:21:38
【问题描述】:

因为我是 vuejs 的新手,所以需要一些语法帮助。如果可以提供帮助,将不胜感激。 我有这个网址:

 response = await this.$axios.get('url/john/mychart?start_date=`${newStartDate}`&end_date=`${newEndDate}`',)

另外,我从这里得到这些日期:

  let myCurrentDate = new Date()
    let myPastDate = new Date(myCurrentDate)
    myPastDate.setDate(myPastDate.getDate() - 8)
    let newStartDate = myCurrentDate.toJSON().slice(0, 10).replace(/-/g, '/');
    let newEndDate = myPastDate.toJSON().slice(0, 10).replace(/-/g, '/');

问题是我无法在此处获取开始日期和结束日期:

start_date=${newStartDate}&end_date=${newEndDate}

感谢您的帮助

【问题讨论】:

  • 您面临的问题是什么?请尝试详细说明。它可以帮助其他贡献者更好地理解您的问题。

标签: vue.js nuxt.js


【解决方案1】:

随便用

response = await this.$axios.get(`url/john/mychart?start_date=${newStartDate}&end_date=${newEndDate}`)

请注意,您必须删除 , before )。 或

response = await this.$axios.get('url/john/mychart?start_date=' + newStartDate + '&end_date=' + newEndDate);

【讨论】:

    猜你喜欢
    • 2021-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-18
    • 1970-01-01
    相关资源
    最近更新 更多