Mix Razor and Javascript code

前端 未结 7 1924
情歌与酒
情歌与酒 2020-11-22 16:21

I\'m pretty confused with how to mix razor and js. This is the current function I am stuck with:



        
7条回答
  •  萌比男神i
    2020-11-22 16:47

    A non conventional method to separate javascript from the view, but still use razor in it is to make a Scripts.cshtml file and place your mixed javascript/razor there.

    Index.cshtml

    @section scripts { @Html.Partial("Scripts") }

    Scripts.cshtml

    
    

提交回复
热议问题