Element UI 中scope用法


一個固定用法: <template slot-scope="scope">

我們主要說一下這個scope是個什么東西,scope就相當於是tableData的一行,與el-table-column唯一對應,具體試驗代碼如下,

     <el-table-column
        label="操作"
        width="100">
        <template slot-scope="scope">
          <el-button @click="update(scope)" type="text" size="small">編輯</el-button>
          <el-button type="text" size="small" @click="del(scope.$index)">刪除</el-button>
        </template>
      </el-table-column>

js方法 console.log(scope)  通過在控制台觀察,發現每一行輸出的scope都是當前行的數據,包含$index:當前行的索引,column,row,store等,如下:

{row: {…}, column: {…}, $index: 0, store: TableStore, _self: VueComponent}
$index: 0
column: {…}
row: {…}
store: TableStore {__ob__: Observer}
_self: VueComponent {_uid: 486, _isVue: true, $options: {…}, _renderProxy: Proxy, _self: VueComponent, …}
__proto__: Object

 


免責聲明!

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



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