vue 如何像 router-link 组件一样 , 通过设置一个tag属性值, 然后生成对应的html标签 ?

vue 如何像 router-link 组件一样 , 通过设置一个tag属性值, 然后生成对应的html标签 ?

例如:

<component tag="li"></component>

对应生成 <li></li>标签

阅读 2.4k
1 个回答

直接这么写就行

<component :is="'a'"></component>
<component :is="'h2'"></component>
<component :is="'li'"></component>
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题