在视图中,
@{
Layout = "~/Views/Shared/site.cshtml";
ViewBag.Title = "Organizations";
var organizations = "";
foreach (var org in Model)
{
organizations += "'" + org.Name + "':'" + org.Id + "',";
}
organizations = organizations.Substring(0, organizations.Length - 1);
}
结果操作:organizations = "'Passport':'14f0eac0-43eb-4c5f-b9fe-a09d2848db80','Bank':'ad1d77d8-7eb1-4a4c-9173-b0f2f7269644'";
输出部分JS代码中的数据。但是在浏览器中查看页面的源代码时,并没有得到想要的东西。有什么问题?如何进行正常报价?
JS:"data": "@organizations"
结果在视图网页返回"data": "'Passport':'14f0eac0-43eb-4c5f-b9fe-a09d2848db80','Bank':'ad1d77d8-7eb1-4a4c-9173-b0f2f7269644'"