development, vue

Vue Slot组件调用父组件方法

By jere on 2018-10-23 0 Comments

使用

<common-list>
    <template slot-scope="scope">
       <span class="link-type" @click="scope._self.handleUpdate(scope.row)">{{ scope.row.name }}</span>
    </template>
</common-list>

CommonList定义

<template>
    <div>...</div>
</template>

export default {
    methods: handleUpdate(row) {
        //...
    }
}

通过console.log发现, scope里的self 就是Vue Element他自己啊。
这样方便了可以直接写slot里的内容了。

打赏

Leave a comment

您的电子邮箱地址不会被公开。 必填项已用*标注