~/ equivalent in javascript

后端 未结 12 1934
萌比男神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:06

    You could also use the asp.net feature VirtualPathUtility:

    
    

    Notice: I don't encode the path to a JSON-string (escape quotes, control characters etc). I don't think this is a big deal (quotes for example aren't allowed unescaped in an URL), but one never knows...

提交回复
热议问题