Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can provide dynamic component with template tag, 能否支持 动态组件 的is属性是空/template #3092

Closed
pangao66 opened this issue Jan 25, 2021 · 1 comment

Comments

@pangao66
Copy link

pangao66 commented Jan 25, 2021

What problem does this feature solve?

now the dynamic component the attribute of "is" must be a html tag or a componet tag,
sometimes , I want the dynamic component the attribute of "is" is empty
such as

<component :is="showTip? 'el-tootip':''template"  >
<el-button>button</el-button>
</compnent>

the example I want if the showTip is true, the button will be wrapped by a tooltip component
else if the showTip is false, there is nothing wrapped the button
so I want vue can provide the component :is with empty
现状是 动态组件 component :is的 is属性只能是 html标签或者已经注册的组件标签
但有时 需求想 is是个空值,
比如有这样的需求

<component :is="showTip? 'el-tootip':''template"  >
<el-button>button</el-button>
</compnent>

给一个button添加tooltip功能, 提供一个 showTip的字段, 如果为true则 则button组件会被一个tooltip组件包裹, 如果此字段为false则不会被任何元素包裹,
所以希望vue能够提供 动态组件 is属性是空值

What does the proposed API look like?

<component :is="showTip? 'el-tootip':''template"  >
<el-button>button</el-button>
</compnent>
<component :is="showTip? 'el-tootip':''"  >
<el-button>button</el-button>
</compnent>
@HcySunYang
Copy link
Member

你可以提供一个 wrapper 组件,我给你提供了一个例子:https://codesandbox.io/s/nervous-mcnulty-necyx?file=/src/App.vue

@github-actions github-actions bot locked and limited conversation to collaborators Oct 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants