反应插入变量到标签

问题描述

我想将库中的图标动态插入到react元素中。不幸的是,它是作为字符串而不是图标呈现的。。。

@Prop() icon: string;

  render() {
    const xmlIcon = `<i-fill-${this.icon}/>`;
    const { href,type,target,rel } = this;
    let Tag = href ? "a" : "button";
    let attrs = Tag === "a" ? { href,rel } : { type };

    return (
      <Host>
        <Tag {...attrs}>
          <slot />
          {xmlIcon}
        </Tag>
      </Host>

呈现
  <pw-button-primary-big icon="debt">
    Title
  </pw-button-primary-big>

显示

enter image description here

接受字符串作为道具并将其插入标记以创建呈现的标签的最佳方法是什么?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)