当前位置:   article > 正文

vue和element ui用el-switch滑动开关改变每行的状态,源码例子_element滑动开关

element滑动开关

源码例子:
在这里插入图片描述

	<el-table ref="multipleTable" :data="tableData" border tooltip-effect="dark" style="width: 100%" class="table_box">
			<el-table-column prop="status" label="是否上架" align="center" min-width="120">
				<template slot-scope="scope">
					<el-row>
						<el-col :span="12">
							<span v-if="scope.row.status == '2'">上架</span>
							<span v-if="scope.row.status == '1'">下架</span>
						</el-col>
						<el-col :span="12">
							<el-switch v-model="scope.row.status" active-color="#13ce66" inactive-color="#ff4949" active-value="2"
							 inactive-value="1" @change="handleSwitch(scope.$index,scope.row)" />
						</el-col>
					</el-row>
				</template>
			</el-table-column>
		</el-table>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
		handleSwitch(index, row) {
				const param = {	
					id: row.id,
					status: row.status
				}
				this.changeStatus(param)//更新状态的接口
					.then(res => {
						console.log(res)
						this.getList()
					})
					.catch(() => {})
			}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/740139
推荐阅读
相关标签