Vue Slots
子组件vue
<template>
<div>
<slot v-if="slots.header" name="header"></slot>
<slot></slot>
<slot name="footer"></slot>
</div>
</template>
<script>
export default {
mounted() {
console.log(this.$slots, '$slots')
},
computed: {
slots() {
return this.$slots
}
}
}
</script>
父组件vue
<template>
<div class="test">
<test>
<div slot="header">slot: header</div>
<div slot="header">slot: header</div>
<div>slot default</div>
<div slot="footer">slot: footer</div>
</test>
</div>
</template>
<script>
import Test from './test'
export default {
components: { Test },
}
</script>

Vue Slots的更多相关文章
- [Vue @Component] Place Content in Components with Vue Slots
Vue's slots enable you to define where content of a component should land when you define the conten ...
- 手写vue-router & 什么是Vue插件
博文分享 这篇文章你可以学习到: 实现一个自己的vue-router 了解什么是Vue的插件 学习b站大佬后做的笔记整理和源码实现 1.1.3一步一步带你弄懂vue-router核心原理及实现哔哩哔哩 ...
- (译文)开始学习Vue.js特性--Scoped Slots
什么是scoped slots A scoped slot is a special type of slot that functions as a reusable template (that ...
- vue 2.0 scopedSlots和slots在render函数中的应用示例
渲染内容为: hello from functional render scopedSlots render scopedSlots named slot of render hello from f ...
- 一例完全理解vue 2.0 的slots 和 functional render
https://jsfiddle.net/pronan/mjqpmw0u/ 通过调节plan="bbb"的值, 比如换成plan="children",你会发现 ...
- Vue.js 系列教程 2:组件,Props,Slots
原文:intro-to-vue-2-components-props-slots 译者:nzbin 这是关于 JavaScript 框架 Vue.js 五个教程的第二部分.在这一部分,我们将学习组件, ...
- Vue:渲染、指令、事件、组件、Props、Slots
如果要我用一句话描述使用 Vue 的经历,我可能会说“它如此合乎常理”或者“它提供给我需要的工具,而且没有妨碍我的工作”.每当学习 Vue 的时候,我都很高兴,因为很有意义,而且很优雅. 以上是我对 ...
- vue slot及用法,$slots访问具名slot
- Vue.js起手式+Vue小作品实战
本文是小羊根据Vue.js文档进行解读的第一篇文章,主要内容涵盖Vue.js的基础部分的知识的,文章顺序基本按照官方文档的顺序,每个知识点现附上代码,然后根据代码给予个人的一些理解,最后还放上在线编辑 ...
随机推荐
- Python Ethical Hacking - Malware Analysis(1)
WRITING MALWARE Download file. Execute Code. Send Report. Download & Execute. Execute & Repo ...
- echarts 踩坑 : 为什么效果出不来?看看有没有正确引入
今天我要给 echarts 组件加个 dataZoom 功能,结果发现没有效果. 后来发现是引入 echarts 模块的问题. 如果是按需引入的话,必须引入相应的功能模块才能使用相应的功能. 举例: ...
- final总结
final 1.类 不含任何子类,有父类(太监类):其中方法不能覆盖重写. 2.方法 最终方法,不能被覆盖重写. 3.局部变量 赋值后不能改变,只能赋一次值. 4.成员变量 <1>由于成员 ...
- Spring葵花宝典
一 Spring简介 Spring是一个轻量级的控制反转(IoC)和面向切面(AOP)的容器框架 为了解决企业应用开发的复杂性而创建 二 Spring功能 1. 方便解耦 简化开发 Spring就是一 ...
- 一个完全关于android编程的技术博客网站
https://www.oschina.net/android/96/file-process
- pandas之时间数据
1.时间戳Timestamp() 参数可以为各种形式的时间,Timestamp()会将其转换为时间. time1 = pd.Timestamp('2019/7/13') time2 = pd.Time ...
- 关于RecyclerView(二)设置EmptyView
首先重写一个RecyclerView类 package com.onepilltest.others; import android.content.Context; import android.s ...
- feign.FeignException: status 404 reading xxService#xxmethod
做乐优商城授权中心出错 public interface UserApi { @GetMapping("query") public User queryUser( @Reques ...
- __slots__属性
使用__slots__时,子类不受影响 class Person(object): __slots__ = ("name","age") def __str__ ...
- PHP trigger_error() 函数
定义和用法 trigger_error() 函数创建用户自定义的错误消息. trigger_error() 函数用于在用户指定的条件下触发一个错误消息.它可以与内建的错误处理程序一起使用,或者与由 s ...