angular - 如何使用 xlink:href 主机绑定获取组件以在启用 ivy 的情况下以角度工作
问题描述
我无法为此做出成功的 plunkr,所以无论如何我都试图根据描述来问这个问题。我们有一个 NG 组件,它使用主机绑定将图标属性绑定到 svg xlink:href。
@Component({
selector: 'use', // tslint:disable-line
template: ``
})
export class SohoIconUseComponent {
// This works but we cant use it because it fails on Safari 12
// @HostBinding('attr.href') get href(): string {
// return '#' + this.icon;
// }
// This does not work
@HostBinding('attr.xlink:href') get xhrefLink(): string {
return '#' + this.icon;
}
@Input() icon: string;
}
因此,一旦我们升级到 NG 9 并启用 Ivy,我们的图标就会停止工作。但是如果我们禁用 ivy,它将与 href 或 xlink:href 一起使用。
尝试在 Ng 回购中寻找错误,但似乎无法解决这个问题?有什么想法吗?
我的一个想法是您setAttributeNS
有时必须使用来设置 xlink:href。我想知道我是否需要以不同的方式绑定主机绑定,以便它使用setAttributeNS
?
解决方案
推荐阅读
- sql - How to select a sql string parameter as an original value with multi lines
- android - Using Constraint Layout for Custom views
- python - Storing a function call in a Django model
- ios - 动画 UIImageView 高度约束空白
- hyperledger-fabric - 超级账本结构分布式存储所需的建议
- scala - 在 scala 应用程序中缓存 Cassandra 表
- ios - iOS - 如何从公共存储中下载所需的 .mov(H.264 AVC) 间隔(保存在手机上,例如仅从 53 秒到 60 秒)
- react-native - React Native InjectJavaScript
- json - 格式化子对象
- python - Pandas 数据框列从其他列中选择值