[javascript] elementui下el-switch组件的使用

切换状态时使用的这种开关样式的组件,比较显眼和方便

先把html组件结构加上,  尽量把值改成true false的形式,其他值容易出问题,在table中使用如下所示

                                <el-table-column
                                    prop="id"
                                    label=操作">
                                    <template slot-scope=scope">
                                        <el-switch
                                            v-model=scope.row.status
                                            :active-value=true
                                            :inactive-value=false
                                            active-color=#13ce66
                                            inactive-color=#ff4949
                                            @change=switchStatus(scope.row.status,scope.row.id)"
                                            >
                                        </el-switch>
                                        <el-button @click=deleteAccount(scope.row.id)" type=text" size=small">删除</el-button>
                                    </template>
                                </el-table-column>

方法部分这样写

        //切换状态
       switchStatus:function(status,id){
           var data={
               status:status==true?1:0,id:id,}
           $.post(index.php?r=media/switchtoutiaoaccoutstatus

 

相关文章

el-menu 有个属性 :default-active="curActive"...
基础用法1<el-inputv-model="input1"palcehode...
 1.安装element-uinpminstallelement-ui-S 2.在main.js中i...
layout布局通过基础的24分栏,可进行快速布局基础布局使用单...
 今天做一个选择年份的功能,直接调用了ElementUI里面的Dat...
  that.end 即为结束日期