john0king
john0king
  • 发布:2021-01-07 12:22
  • 更新:2021-01-07 12:22
  • 阅读:434

【报Bug】 这个 empty 组件的 empty属性 无法响应式, 特别是配合 array.length < 1 的情况

分类:uni-app

产品分类: uniapp/小程序/微信

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: win

HBuilderX版本号: 3.0.4

第三方开发者工具版本号: 2.0.0-29820201110001

基础库版本号: 2.14.1

项目创建方式: CLI

CLI版本号: 2.0.0-29820201110001

示例代码:

组件

<template>  
    <view class="root" :style="{ minHeight: minHeight + 'rpx' }">  
        <slot v-if="!empty"></slot>  
        <view v-else class="empty">  
            <image src="@/static/images/empty.png" mode="widthFix"></image>  
            <text v-if="text!='' && text != null">{{text}}</text>  
        </view>  
    </view>  
</template>  
<script lang="ts">  
import Vue from 'vue';  
export default Vue.extend({  
    name:'empty',  
    props:{  
        empty:{  
            type: Boolean,  
            default: false,  
        },  
        text:{  
            type:String,  
            default: ''  
        },  
        minHeight:{  
            type:Number,  
            default:100  
        }  
    },  
    watch:{  
        empty:{  
            handler(v){  
                console.log(`empty state :${v}`);  
            },  
            immediate:true,  
        }  
    }  
})  
</script>

使用

<empty :empty="news.length <  1">  
<navigator  v-for="item in news">...</navigator>  
</emtpy>  

操作步骤:

上面的代码

预期结果:

当 news 的length 为0 时, 显示 empty组件的内容
当 news 的length > 0 是, 显示 模板的内容

实际结果:

emtpty 默认是 true, 就是始终是true,
默认是false 就 始终是false

bug描述:

如题, 请看下方代码

2021-01-07 12:22 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复