element uielswitch开关组件具有先改变开关值再传值的特点。(先改后传)
比如

<el-switch v-model="scope.row.open" :active-value="1" :inactive-value="0" @change="handleTuningMode1(scope.row)"></el-switch>

如果此时开关是开着的,也就是说open值是”1″,那么当我们触发change事件的时候,传过去的open值是关闭的“0”值。

elementUI switch组件

解决办法

<el-switch v-model="scope.row.open" :active-value="1" :inactive-value="0" @click.native.prevent="handleTuningMode(scope.row)" disabled></el-switch>
disabled样式问题

设置disabled后开关会有鼠标禁用的样式及透明度的变化,我们需要修改

<style>
/* 修改elementUI-switch组件 disabled样式 */
.el-switch.is-disabled {
 opacity: 1;
}
.el-switch.is-disabled .el-switch__core, .el-switch.is-disabled .el-switch__label {
cursor: pointer !important;
}
</style>

建议在写有scopedstyle标签修改,是因为scoped表示它的样式作用于当下的模块,很好的实现了样式私有化的目的

<style lang="less" scoped>
</style>

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注