亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

element中el-switch的v-model自定義值的實現(xiàn)

 更新時間:2023年11月29日 09:32:01   作者:老馬甲  
在el-switch中設置active-value和inactive-value屬性,接受Boolean, String或Number類型的值,本文就來介紹一下element中el-switch的v-model自定義值的實現(xiàn),感興趣的可以了解一下

一、問題

element中的el-switch的值默認都是truefalse,但是有些時候后端接口該字段可能是0或者1,如果說再轉(zhuǎn)換一次值,那就有點太費力了。如下所示:

<template>
    <el-switch
        inactive-text="否"
        active-text="是"
        v-model="status"
        @change="changeSwitch"
    />
</template>
<script>
export default {
    data() {
        return {
            status: false
        }
    },
    methods: {
        changeSwitch(e) {
        	console.info(e)
        }
    }
}
</script>

二、解決

el-switch中設置active-valueinactive-value屬性,接受Boolean, StringNumber類型的值

<el-switch
    inactive-text="否"
    active-text="是"
    active-value="1"
    inactive-value="0"
    v-model="status"
/>

三、官方文檔

到此這篇關于element中el-switch的v-model自定義值的實現(xiàn)的文章就介紹到這了,更多相關element el-switch v-model自定義值內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家! 

相關文章

最新評論