回答1

You need to escape the @ for Razor, not for the JS string, itself. So, just use @@. Once Razor renders the HTML, it will end up as just an @.

 

回答2

Escaping with @@ works for me

var emailReg = '[-0-9a-zA-Z.+_]+@@[-0-9a-zA-Z.+_]+\.[a-zA-Z]{2,4}';

and output HTML is

var emailReg = '[-0-9a-zA-Z.+_]+@[-0-9a-zA-Z.+_]+\.[a-zA-Z]{2,4}';

 

Escape @ character in razor view engine会

回答1

@@ should do it.

评论

The best solution would be using the HTML-encoded character string for the @-character: @ Dec 18 '13 at 12:45

 

相关文章:

  • 2022-02-21
  • 2022-12-23
  • 2022-12-23
  • 2021-07-23
  • 2021-06-05
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-23
  • 2021-11-19
  • 2022-12-23
  • 2021-07-24
  • 2021-09-12
  • 2021-10-06
相关资源
相似解决方案