如何在 vue 中将类添加到"template"标签?



我需要知道如何将类添加到"模板";标签在vue。

<template 
#popover
class: templateClass // Is it possible to add a class in here?
>
<router-link
v-close-popover
to="/somewhere"
>
Go to the page
</router-link>
</template>

不能将任何类绑定到模板标记,因为模板标记本身不会为自己呈现元素。尽管有相反的评论,但你试图实现的目标是不可能的。Vue2的组件需要根元素是有原因的。将#templateRef添加到模板标记中只是v-slot的简写(请参阅Vue中的散列标记(#(是什么意思?(在这种情况下基本上对你没有任何帮助。

最新更新