如何将带有连字符和冒号的属性添加到剃刀中的 Html 辅助方法? (vuejs 语法)
How to add attributes with hyphen and colon to Html Helper methods in razor? (vuejs syntax)
我想添加 v-on:click 或 @click 如下 html 辅助方法:
@Html.TextBoxFor(x => x.ItnScanCaseCode, new { @id="txtid",@click = "onchangeevent();" })
怎么做?
您可以像这样为 htmlAttributes
使用 Dictionary
:
@Html.TextBoxFor(x => x.ItnScanCaseCode, htmlAttributes: new Dictionary<string, object> {
{ "v-on:click", "onchangeevent()" },
{ "id", "txtid" }
})
您只需使用下划线而不是 - razor 会将其替换为连字符。就这么简单!!!
@Html.TextBoxFor(x => x.ItnScanCaseCode, new { @id="txtid",v_on:click = "onchangeevent();" })
我想添加 v-on:click 或 @click 如下 html 辅助方法:
@Html.TextBoxFor(x => x.ItnScanCaseCode, new { @id="txtid",@click = "onchangeevent();" })
怎么做?
您可以像这样为 htmlAttributes
使用 Dictionary
:
@Html.TextBoxFor(x => x.ItnScanCaseCode, htmlAttributes: new Dictionary<string, object> {
{ "v-on:click", "onchangeevent()" },
{ "id", "txtid" }
})
您只需使用下划线而不是 - razor 会将其替换为连字符。就这么简单!!!
@Html.TextBoxFor(x => x.ItnScanCaseCode, new { @id="txtid",v_on:click = "onchangeevent();" })