vue2.2——cdn如何使用插槽

<mynav>
  <h1 slot="h1">我是具名插槽</h1>
  <h2 slot="h2">我没有命名</h2>
</mynav>

let cp_template = {
    mynav: {
        template: `
            <div style="color:red;">
                <slot name="h2"></slot>
                <slot name="h1"></slot>
            </div>
        `
    }
}

const apps = new Vue({
    el: '#app',
    data() {
        return {
            msg: 'hello',
            wkblxt: {},
            menuIndex: 0
        }
    },
    created() {
        this.wkblxt = wkblxt.wkblxt
    },
    components: {
        'mynav': cp_template.mynav
    },
    mounted: {
    },
    methods: {

    }
})

posted @ 2024-05-27 10:06  lambertlt  阅读(11)  评论(0编辑  收藏  举报