c# - 使用 TagBuilder 类 C# 插入属性
问题描述
我想知道是否有一种方法可以在不使用 TagBuilder 类的 MergeAttributes 或 MergeAttribute 方法的情况下在脚本标记中插入属性。
我有一个属性数据列表:
AttributeDataList = new List<AttributeData>
{
new AttributeData()
{
Key = "",
Value = ""
}
},
在我负责创建脚本的助手中,我进行了以下检查:
if (script.AttributeDataList.Count > 0)
{
foreach (var attr in script.AttributeDataList)
{
scriptTag.MergeAttribute(attr.Key, attr.Value);
}
}
现在假设我想插入“async”或“defer”属性而不使用“async=async”,我该怎么做?TagBuilder 类似乎没有提供这样的方法,我得到的是async=""
我正在考虑使用正则表达式,并将“=”替换为“”,但这种模式@"=\\"""
似乎不起作用。
有解决方案吗?非常感谢
解决方案
推荐阅读
- xml - Spark DataFrame 到 xml 文件
- c# - xamarin 主从页面 CS0102 nand CS0229
- ios - iOS 在前台推送通知 - 检测通知的横幅何时被用户忽略
- julia - 替换数组中的特定元素也更改其他元素
- flutter - 如何去除 Flutter Widget 上 TextField 的背景颜色?
- raku - 滑动散列和 slurpy 自动变量的默认值
- api - InputPhoneContact 没有 len()
- javascript - 将文件放入驱动器 API v3
- python - Python 中的 Cplex - 学生许可
- javascript - 使用我的库对应的 .d.ts 代码检查我的库 .js 代码