vue動態綁定樣式

<view  v-for="(list,index) in lists" :key="index">     

<text class="m_icon " :class="list.ref == 0 ? 'bg' : 'bg1'">{{list.icon}}</text>

或者

<text class="m_icon bg" v-if="list.ref == '0'">{{list.icon}}</text>
<text class="m_icon bg1" v-if="list.ref == '1'">{{list.icon}}</text> 

</view>

<script>
    export default {
        data() {
            return {

                lists: [{
                        logo: '/static/image/user16.png',
                        company: 'Optobiomed',
                        icon: 'M',
                        type: '醫療器械',
                        num: '單位編號:SHCPCH180402333',
                        ref: 0
                    },
                    {
                        logo: '/static/image/user17.png',
                        company: '福進YVESOM',
                        icon: 'B',
                        type: '檢測分類',
                        num: '單位編號:SHCPCH180402333',
                        ref: 1
                    }

                ],

            }
        },
        methods: {

        }
    }
</script>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章