我需要在JavaScript函数中评估剃刀变量。给定以下代码:
@{var unseenNotificationsExist = false;}
@foreach(var notification in viewModel)
{
if (notification.WasSeen == false)
{
unseenNotificationsExist = true;
break;
}
}
我需要像这样在JavaScript中评估
unseenNotificationsExist
变量: if(@unseenNotificationsExist == true)
$('#unseenNotifCount').addClass('notifNotSeen');
然而,在我调试JavaScript代码时,我得到了这个:
if(True == true)
我还遇到了以下错误:
未捕获的ReferenceError:True未定义