~/ equivalent in javascript

后端 未结 12 1981
萌比男神i
萌比男神i 2020-12-12 19:11

Any smart way of doing a \"root\" based path referencing in JavaScript, just the way we have ~/ in ASP.NET?

12条回答
  •  佛祖请我去吃肉
    2020-12-12 20:01

    Use base tag:

    
       
    
    

    ...

    from now any link use on this page, no matter in javascript or html, will be relative to the base tag, which is "http://www.example.com/myapp/".

提交回复
热议问题