zoukankan      html  css  js  c++  java
  • [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",data); 
           },

     

  • 相关阅读:
    刷题238. Product of Array Except Self
    刷题236. Lowest Common Ancestor of a Binary Tree
    刷题208. Implement Trie (Prefix Tree)
    A1070
    A1048
    A1050
    A1041
    A1092
    A1084
    n进制转十进制
  • 原文地址:https://www.cnblogs.com/taoshihan/p/12916701.html
Copyright © 2011-2022 走看看