事实上,剑道模板中的斜线用于逃避特殊符号。在你的情况下,我会建议你逃脱与额外的页岩slahes。
这里是我想在我的身边:
<form id="myForm" action="/" method="post">
<div id="result">
</div>
<input type="submit" value="Go" />
</form>
<script id="foo" type="text/kendo">
templatE:
@Html.TextBoxFor(m=>m.Name)
</script>
<script type="text/javascript">
var html = $('#foo').html().replace(/\\/g, '\\\\');
html = html.replace(/#/g, /\#/);
var template = kendo.template(html);
$('#result').html(template({}));
$('#myForm').kendoValidator();
</script>
在机型上装饰有以下属性:
[RegularExpression(@"^([a-zA-Z0-9\s\-]){0,}$")]
public string Name { get; set; }