Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我要实现:
@{ var myVariable = "GenericId" + UniqueId; }
并使用myVariablejQuery 选择器:
myVariable
$('#@myVariable').doSomething();
但它不起作用。
这可能吗?
您可以使用括号创建一个显式表达式,并告诉 Razor 您希望它将其解释为代码:
$('#@(myVariable)').doSomething();