【发布时间】:2020-02-28 19:56:25
【问题描述】:
我有一个场景,div 的内容将根据 java-script 函数返回的值显示
伪 HTML:
<div>
if(true==myfunction())
{
<p>True is returned from the javascript function</p>
}
else
{
<p>False is returned from the javascript function</p>
}
</div>
伪javascript函数
myFunction()
{
var x = false;
// Some code to decide value of x.
return x;
}
我使用的是 Asp.net 核心,我的 Javacript 代码存在于 site.js 中,html 代码存在于 cshtml 中。
如果有人可以就如何实现这一目标提出建议,那将非常有帮助。 注意:呈现的代码不是实际代码,而是代表实际场景。
【问题讨论】:
-
您使用的是剃刀视图吗?
标签: javascript html asp.net-core conditional-rendering