[Vue @Component] Place Content in Components with Vue Slots
Vue in with Component content Components Place Slots
2023-09-14 09:00:50 时间
Vue's slots enable you to define where content of a component should land when you define the content inside of a parent component. You can also name slots to arrange the elements however you'd like and allow your component to build it's own content around the content that will be placed.
main.js:
import Vue from 'vue' import App from './App.vue' new Vue({ render: (h) => ( <App> <h1 slot="header">This is header</h1> <h2 slot="footer">This is footer</h2> </App> ) }).$mount('#app')
App.vue:
<template> <section class="section"> <slot name='header'></slot> <hello-world message="Message from APP"></hello-world> <slot name='footer'></slot> </section> </template>
相关文章
- Vue.js 渲染简写样式存在的问题
- Vue_(组件)实例方法
- VUE - vue.runtime.esm.js?6e6d:619 [Vue warn]: Do not use built-in or reserved HTML elements as component i
- [VueJS + Typescript] Decouple Dependencies Using IoC Containers in Vue with TypeScript and InversifyJS
- [Vue @Component] Extend Vue Components in TypeScript
- [Vue] Code split by route in VueJS
- [Nuxt] Build a Navigation Component in Vue.js and Use in a Nuxt Layout
- [Nuxt] Add Arrays of Data to the Vuex Store and Display Them in Vue.js Templates
- [Nuxt] Update Vuex State with Mutations and MapMutations in Vue.js
- vue.js开发SPA常见问题及解决方法
- vue-cli内部webpack的打包优化
- vue+element列表排序
- [Typescript Kaop-ts] Use AOP in Vue Components with TypeScript and Kaop-ts
- [Vue @Component] Extend Vue Components in TypeScript
- [Vue + TS] Watch for Changes in Vue Using the @Watch Decorator with TypeScript
- [Vue + TS] Create your own Decorators in Vue with TypeScript
- [Nuxt] Navigate with nuxt-link and Customize isClient Behavior in Nuxt and Vue.js
- [Vue] Update Attributes, Classes and Styles in Vue.js with v-bind
- [Vue] Use basic event handling in Vue
- vue快速学习03、ant-design
- Vue学习之--------路由的query、params参数、路由命名(3)(2022/9/5)
- vue路由跳转报错解决
- 092:vue+openlayers 自定义组件(放大、缩小、长度测量、面积测量)
- 079:vue+openlayers点击旋转loading,渲染后取消加载
- uni-app的Vue项目中Echarts的报错提示:[Vue warn]: Error in data(): “ReferenceError: echarts is not defined“