- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在使用 Vuetify 预定义模板“Google 联系人”。
链接:https://vuetifyjs.com/en/examples/layouts/googleContacts
我是 Vuetify 的新手,在理解某些代码时遇到困难。一种是'slot activator'。
示例代码:
<v-list-tile slot="activator">
<v-list-tile-content>
<v-list-tile-title>
{{ item.text }}
</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
谁能告诉我“插槽激活器”是如何工作的?
最佳答案
当你声明一个Vue组件时,你可以创建Named Slots ,这是一个 Vue native 特性(不是来自 Vuetify):
For example, suppose we have an
app-layout
component with thefollowing template:<div class="container">
<header>
<slot name="header"></slot>
</header>
<main>
<slot></slot>
</main>
<footer>
<slot name="footer"></slot>
</footer>
</div>Parent markup:
<app-layout>
<h1 slot="header">Here might be a page title</h1>
<p>A paragraph for the main content.</p>
<p>And another one.</p>
<p slot="footer">Here's some contact info</p>
</app-layout>The rendered result will be:
<div class="container">
<header>
<h1>Here might be a page title</h1>
</header>
<main>
<p>A paragraph for the main content.</p>
<p>And another one.</p>
</main>
<footer>
<p>Here's some contact info</p>
</footer>
</div>
注意 <slot name="header"></slot>
在示例模板声明中(上面的第一个代码块)。当有人使用该组件时,她可以声明 <h1 slot="header">Here might be a page title</h1>
并且此代码将占用 <slot name="header"></slot>
在最终标记中的位置。
这是 <slot>
的演示行动中:
Vue.component('mycomponent', {
template: "#mycomponenttemplate"
})
new Vue({
el: '#app'
});
<script src="https://unpkg.com/vue@2.5.13/dist/vue.min.js"></script>
<div id="app">
<app-layout>
<h1 slot="header">Here might be a page title</h1>
<p>A paragraph for the main content.</p>
<p>And another one.</p>
<p slot="footer">Here's some contact info</p>
</app-layout>
</div>
<template id="mycomponenttemplate">
<div class="container">
<header>
<slot name="header"></slot>
</header>
<main>
<slot></slot>
</main>
<footer>
<slot name="footer"></slot>
</footer>
</div>
</template>
你显示the example :
<v-list-group
...
>
<v-list-tile slot="activator">
...
</v-list-tile>
如您所见,这段代码试图将 v-list-tile
在activator
父组件的 插槽 ( v-list-group
)。
看看the official docs (包括 the old version ),如果 <v-list-group>
没有提及有一个名为 activator
的插槽.
但是看看 <v-list-group>
's SOURCE CODE 很快证明确实存在。
关于vue.js - 'slot activator' 在 vuetify 中如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49079936/
我正在学习 Vue.js,并且正在努力寻找一种组织代码的方法。我试图让一切尽可能模块化,所以在制作 slider 时我做了以下事情: export
我有一个像这样定义的 Web 组件自定义元素。 class Dropdown extends HT
我遇到了这样的崩溃: #0 0x90b05955 in __gnu_debug::_Safe_iterator_base::_M_detach #1 0x90b059ce in __gnu_deb
正如标题中所写 - “信号和插槽”是一种简单的响应式(Reactive)编程方式吗? 最佳答案 Signals/Slots是 Observer Pattern 的实现. 来自维基 Reactive P
我有一个关于太阳系行星列表的 intent 。 { "intent": "PlanetIntent", "slots": [ { "nam
我们的消费计划中有一个 Azure Function v3 实例,其中包括一个暂存槽以减少部署期间的停机时间。 我们的部署流程是: 将代码部署到暂存槽 启动暂存槽 将暂存槽与生产槽交换 停止暂存槽 我
我们的消费计划中有一个 Azure Function v3 实例,其中包括一个暂存槽以减少部署期间的停机时间。 我们的部署流程是: 将代码部署到暂存槽 启动暂存槽 将暂存槽与生产槽交换 停止暂存槽 我
我遇到一个同步组件 JavaScript 在实际显示之前加载的问题。 使用 dynamic-import 导入的组件在需要时使用 v-if 显示以加载它们。当它们被显示时,它们的 JavaScript
我有 6 个 subdag。它们中的每一个都包含一个带有 pool='crawler' 的任务。这需要大量资源,所以我创建了一个池 crawler只有 1 个插槽。 当我运行 DAG 时,似乎绕过了池
Vue 对象有一个非常有用的成员,叫做 $attrs。什么$attrs does 包含所有未被识别为当前组件 props 的属性。 $attrs 的一个很好的例子是 here . 我想知道 $scop
我有一个运行 Node.js 应用程序的 Azure Function App v3,该应用程序具有生产槽和阶段槽。使用在部署中心创建的操作将其部署到 GitHub。我有一项针对 prod 的部署操作
我有一个运行 Node.js 应用程序的 Azure Function App v3,该应用程序具有生产槽和阶段槽。使用在部署中心创建的操作将其部署到 GitHub。我有一项针对 prod 的部署操作
我有一个事件架构: owner: { type: Schema.Types.ObjectId, ref: 'User', required: true }, participa
我想测试这个FooComponent: 它是这样使用的(例如在 ParentComponent 中): 因此,我想测试我的组件对从 slot Prop 调用此“fn
我有一个意图,其中包含三个必需的插槽(我们称它们为:slot_a、slot_b、slot_c),所有类型都是 @系统编号。当检测到意图时,系统会提示我询问缺少的插槽: What's slot_a? 我
我有这个预订表结构 |ID|timeBooked | duration | |2 |2013-05-09 11:10:00| 30 | |1 |2013-05-09 14:
突然开始在所有 Azure App Services 中持续发生使用Deployment Slots . Error Message: "Failed swapping site. Error: Ca
我在我的azure应用程序服务中创建了多个插槽(测试、阶段和产品)。同样,我为每个环境创建了各自的 web.config 文件。我正在测试环境槽中通过 octopus 部署工具部署我的应用程序,因此最
所以我正在尝试使用 C++ 学习 Qt Framework。我正在了解信号和插槽,但我很难创建自定义插槽。因此,当我按照一些教程进行操作时,我的程序出现了以下错误: QObject::connec
如何引用 Vue.js 中的文本? Vue.component('component', { template: ``, created: function() { // i woul
我是一名优秀的程序员,十分优秀!