asp.net core mvc 中在C# 代码中写 js 或html 文本


https://blog.csdn.net/orichisonic/article/details/62046621

 

使用<text>这个伪元素来强制Razor从编译模式返回到内容模式:

 

@foreach ( var item in Model) {
     <text>
       var markerlatLng = new google.maps.LatLng(@(Model.Latitude), @(Model.Longitude));
       var title = '@(Model.Title)' ;
       var description = '@(Model.Description)' ;
       var contentString = '<h3>' + title + '</h3>' + '<p>' + description + '</p>'
  
       var infowindow = new google.maps.InfoWindow({
           content: contentString
       });
  
       var marker = new google.maps.Marker({
           position: latLng,
           title: title,
           map: map,
           draggable: false
       });
  
       google.maps.event.addListener(marker, 'click' , function () {
           infowindow.open(map, marker);
       });
  
    </text>
       }
</script>

--------------------- 本文来自 蓝色水 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/orichisonic/article/details/62046621?utm_source=copy


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM