Vue 中 @click.native.prevent; slot-scope="scope" (scope.$index, scope.row)
看别人博客时看到了 @click.native.prevent;和 slot-scope="scope" (scope.$index, scope.row)于是就查了一下。
@click.native.prevent
1.给vue组件绑定事件时候,必须加上native ,否则会认为监听的是来自Item组件自定义的事件,
2.prevent 是用来阻止默认的 ,相当于原生的event.preventDefault()
<el-dropdown-menu slot="dropdown"> <el-dropdown-item @click.native.prevent="handleEdit(scope.$index, scope.row)">编辑</el-dropdown-item> <el-dropdown-item @click.native.prevent="getUp(scope.$index, scope.row)">上升</el-dropdown-item> <el-dropdown-item @click.native.prevent="getDown(scope.$index, scope.row)">下降</el-dropdown-item> <el-dropdown-item @click.native.prevent="handleDelete(scope.$index, scope.row)">删除</el-dropdown-item> </el-dropdown-menu>
slot-scope="scope" (scope.$index, scope.row)
slot-scope="scope" //取到当前单元格
scope.$index→拿到每一行的index
scope.$row→拿到每一行的数据