Html .NetCore The tag helper ‘option‘ must not have C# in the element‘s attribute declaration area

Html select标签在.net core 版本中调用后台代码出现的问题:

The tag helper 'option' must not have C# in the element's attribute declaration area

Html .NetCore The tag helper ‘option‘ must not have C# in the element‘s attribute declaration area_第1张图片

写法会出现错误提示:

RZ1031: The tag helper 'option' must not have C# in the element's attribute declaration area.

RZ1031:标签帮助器“选项”在元素的属性声明区域中不能有c#。

编辑器认为,@(“...”) 不是一个属性。

解决办法是在每个使用了@(“...”)的option前加上"!"
 @item.Value

Html .NetCore The tag helper ‘option‘ must not have C# in the element‘s attribute declaration area_第2张图片

遇到如上问题可以使用!禁用标签助手即可解决。 

你可能感兴趣的:(.Net,Core,html,.netcore,html)