Set [removed] with TypeScript

后端 未结 2 1956
死守一世寂寞
死守一世寂寞 2020-12-10 10:11

I am getting an error with the following TypeScript code:

 ///
 ///

        
相关标签:
2条回答
  • 2020-12-10 10:32

    you have missed the href:

    Standard, To use window.location.href as window.location is technically an object containing:

    Properties
    hash 
    host 
    hostname
    href    <--- you need this
    pathname (relative to the host)
    port 
    protocol 
    search 
    

    try

     window.location.href = $link.attr('data-href');
    
    0 讨论(0)
  • 2020-12-10 10:50

    window.location is of type Location while .attr('data-href') returns a string, so you have to assign it to window.location.href which is of string type too. For that replace your following line:

    window.location = $link.attr('data-href');
    

    for this one:

    window.location.href = $link.attr('data-href');
    
    0 讨论(0)
提交回复
热议问题