前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >uniapp根据不同的状态渲染不同的标签

uniapp根据不同的状态渲染不同的标签

作者头像
王小婷
发布2021-07-08 10:53:11
1.5K0
发布2021-07-08 10:53:11
举报
文章被收录于专栏:编程微刊
代码语言:javascript
复制
<view class="text-grey text-xs">
                    <button v-if="item.isLeave === 0">离厂解绑</button>
                    <span v-else > {{item.leaveTime | formatDate }} </span>
                    </view>

json数据

代码语言:javascript
复制
{
    "msg": "查询成功",
    "total": 15,
    "code": 1,
    "rows": [{
            "isLeave": 0,
            "leaveTime": "2021-06-23"
        }, {
            "isLeave": 1,
            "leaveTime": "2021-06-24"
        }, {
            "isLeave": 0,
            "leaveTime": "2021-06-25"
        },
        {
            "isLeave": 1,
            "leaveTime": "2021-06-26"
        }
    ]
}

test.vue

代码语言:javascript
复制
<template>
    <view>
        <view class="cu-list menu-avatar">
            <view class="cu-item" v-for="(item,index) in productList" :key="index">
                <view class="">
                    <button v-if="item.isLeave === 0" @click.stop="isLeave()">离厂解绑</button>
                    <view v-else class="text-grey text-xs">{{item.leaveTime }}</view>
                </view>

            </view>
        </view>
    </view>
</template>
<script>
    export default {
        data() {
            return {
                productList: [],
            };
        },
        onLoad() {
            this.getList();
        },
        methods: {
            getList() {
                /* this.$request.get('/api/test.json', {
                    
                }).then(res => {                
                    // 打印调用成功回调
                    console.log(res)
                    this.productList = res.data.rows;
                }) */
                uni.request({
                    url: '/api/test.json',
                    success: (res) => {
                        console.log(res.data);
                        this.productList = res.data.rows;
                    }
                });
            },
        },
    }
</script>
<style>
    page {
        padding-top: 50px;
    }

    .header {
        position: absolute;
        top: 0;
        height: 44px;
        width: 100%;
        line-height: 50px;
        background-color: rgb(45, 47, 186);
        color: #fff;
    }

    .header text {
        display: inline-block;
        text-align: center;
    }

    .cu-bar.fixed,
    .nav.fixed {
        top: 45px;
    }

    .cu-list.menu-avatar>.cu-item {
        height: 92px;
        margin: 10px;
        box-shadow: 0 2px 5px -1px #c4c0c0;
    }
</style>
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档