Vue 中的井号 (#) 是什么意思? [英] What do the hash marks (#) mean in Vue?
问题描述
我是一个相当新的 Vue 开发者.在我们堆栈中的每个地方,我都会在组件组件中看到这样的代码:
<div :aria-label="String(value)";类=文本中心"><v-icon v-if=value === null">mdi-minus</v-icon><v-icon v-else color="red">mdi-close</v-icon>
</模板>
对于我的一生,我无法弄清楚 #item.active
(特别是 #
)实际上做了什么.我们有很多散列项目.像 或
谷歌搜索# 不是一件容易的事情.显然我在我的 Vue 教程中错过了这个特定的视频!我们使用 Nuxt 和 Vuetify,不确定是否有帮助!
正如评论中提到的,#
符号是 v-slot
属性,正如使用 (
v-slot
只允许在代码中使用,以及组件).
I am a rather new Vue developer. Everywhere I go in our stack, I see code like this inside our components components:
<template #item.active="{ value }">
<div :aria-label="String(value)" class="text-center">
<v-icon v-if="value === null">mdi-minus</v-icon>
<v-icon v-else color="red">mdi-close</v-icon>
</div>
</template>
And for the life of me, I am cannot figure out what the #item.active
(specifically the #
) actually does. We have many hashed items. Like <template #item.actions-prepend="{item}">
or <template #toolbar-extension>
Googling a # isn't an easy thing to do. And apparently I missed this specific video in my Vue tutorials! We use Nuxt and Vuetify, not sure if that helps!
As mentioned in the comments, the #
symbol is a shorthand for the v-slot
attribute, as hinted by the usage of <template>
(which v-slot
only allows to be used on, as well as components) in your code.
这篇关于Vue 中的井号 (#) 是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!