我一直在尝试遵循https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/authoring?view=aspnetcore-2.1来让标签助手工作,但无论如何我确实在智能感知中无法识别它们,在生成 html 的代码中没有断点,并且元素没有转换。
这是我的 EmailTagHelper.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.TagHelpers;
namespace eHealthy.TagHelpers
{
public class EmailTagHelper : TagHelper
{
public override void Process(TagHelperContext context, TagHelperOutput output)
{
output.TagName = "a"; // Replaces <email> with <a> tag
}
}
}
这是我的 _ViewImports.cshtml
@using Microsoft.AspNetCore.Identity
@using eHealthy.Models
@using eHealthy.Models.AccountViewModels
@using eHealthy.Models.ManageViewModels
@using eHealthy.Helpers;
@using eHealthy.TagHelpers;
@addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers"
@addTagHelper "*, eHealthy.TagHelpers"
这是我尝试调用助手的页面
@model EditViewModel
@{
ViewBag.Title = "title";
Layout = "_Layout";
}
@*<h2>title</h2>*@
<form method="post">
<email>
potato
</email>
</form>
<input type="hidden"/>
杨__羊羊
相关分类