在el-table的表格中嵌入el-switch

<el-table :data="tableData" border style="width: 100%" class="table">
	<el-table-column prop="state" label="状态" width="90">
        <template slot-scope="scope">
            <el-switch v-model="scope.row.state" @change="stateChanged(scope.row)" />
        </template>
    </el-table-column>
</el-table>

其中scope.row.state为switch对应的值,stateChanged为switch改变时触发的方法

<template slot-scope="scope">
    <el-switch v-model="scope.row.state" @change="stateChanged(scope.row)" />
</template>

你可能感兴趣的:(前端,javascript,前端,开发语言)