关于slot-scope="scope"

是什么:作用域插槽

做什么:解决父组件模板的所有东西都会在父级作用域内编译;子组件模板的所有东西都会在子级作用域内编译------父组件的模板是无法使用到子组件模板中的数据

slot-scope的出现却实现了父组件调用子组件内部的数据,子组件的数据通过slot-scope属性传递到了父组件

怎么做:

<template slot-scope="scope">
<el-tooltip effect="dark" content="修改角色" placement="top" :enterable='false'>
<el-button type="primary" icon="el-icon-edit" size="mini" @click="changeUser(scope.row.id)" ></el-button>
</el-tooltip>
scope会得到当前模板的数据

 

posted @ 2019-07-26 15:51  Front-end_rookie  阅读(2776)  评论(0编辑  收藏  举报