我已经从ASP.NET核心复制了电子邮件代码助手的演示。
https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/authoring
当我在我的视图页面上创建一个如下所示的标记时:
<div>
<Email MailTo="abc"></Email>
</div>
我希望公共属性MailTo将被设置但不是(当我调试时,它显示为null)。但是,当我从TagHelperOutput获取输出属性时,如下所示:
var mailToWorks = output.Attributes["MailTo"].Value.ToString();
mailToWorks获得了“abc”,正如我所料,但是没有设置公共属性MailTo。我的Tag Helper来源如下。
[HtmlTargetElement("Email")]
public class EmailTagHelper : TagHelper
{
private const string EmailDomain = "contoso.com";
// Can be passed via <email mail-to="..." />.
// Pascal case gets translated into lower-kebab-case.
public string MailTo { get; set; }
public override void Process(TagHelperContext context, TagHelperOutput output)
{
var mailToWorks = output.Attributes["MailTo"].Value.ToString();
output.TagName = "a"; // Replaces <email> with <a> tag
var address = MailTo + "@" + EmailDomain;
output.Attributes.SetAttribute("href", "mailto:" + address);
output.Content.SetContent(address);
}
}
答案 0 :(得分:0)
如果要关闭转小写字母的翻译,可以使用flutter_launcher_icons
。
HtmlAttributeNameAttribute