日期选择器onselect使用变量重定向


Datepicker onselect redirect with variable

选择日期时,我希望将该日期插入链接并加载。

$(function() {
    $( "#datepicker" ).datepicker({
        dateFormat: 'yy-mm-dd',
            onSelect: function(date) {
                window.location.replace("http://localhost/news-archive/$date/-/");
            }
    });
  })

函数有效,唯一的问题是如何在链接中插入日期值?提前谢谢。

try:

window.location.replace("http://localhost/news-archive/"+date.contat("/-/"));