最近自己在練手項目用到了VUE 綁定屬性的時候發現 有: -符號
這樣顯然是不支持的。之前發現 v-on 這種-符號也是不支持的 但是可用 @v_on 替代。可是找遍了所有資料也沒找到:轉義符
當時想到的思路就是將attribute 屬性這塊改成string 字符串形式
增加一個擴展方法
using Microsoft.AspNetCore.Html; using Microsoft.AspNetCore.Mvc.Rendering; using System.Collections.Generic; namespace HM.HouseCloud.Extensions { public static class SelectExtensions { public static IHtmlContent HtmlAttributesCustom(this IHtmlContent htmlContent, Dictionary<string,string> dic) { TagBuilder content = (TagBuilder)htmlContent; foreach (var item in dic) { content.Attributes.Add(item); } return content; } } }
搞定!!!