欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

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

一、問(wèn)題

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

<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中設(shè)置active-valueinactive-value屬性,接受Boolean, StringNumber類型的值

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

三、官方文檔

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

相關(guān)文章

最新評(píng)論