Using Razor within JavaScript

后端 未结 12 2517
萌比男神i
萌比男神i 2020-11-22 04:12

Is it possible or is there a workaround to use Razor syntax within JavaScript that is in a view (cshtml)?

I am trying to add markers to a Google map...

12条回答
  •  爱一瞬间的悲伤
    2020-11-22 05:02

    There is also one more option than @: and .

    Using }

    Pros of this manner is that it doesn't mix JavaScript and Razor too much, because mixing them a lot will cause readability issues eventually. Also large text blocks are not very readable either.

提交回复
热议问题