v-slot vue2.6新增指令使用指南
抽离的子组件 <template> <div class="wrapper"> <slot name="demo" :msg="msg" text="this is a slot demo , ">this is demo slot.</slot> </div> </template> <script> export default { components: {}, props: {}, data() { return { msg: 'nmb' } }, watch: {}, computed: {}, methods: {}, created() {}, mounted() {} } </script> <style lang="scss" scoped> .wrapper { } </style>
某组件内使用抽离组件 <father> <template v-slot:demo="scope"> sb <p>{{ scope.text }}{{ scope.msg }}</p> </template> </father>