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→拿到每一行的數據


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM