小傻
小傻
  • 发布:2021-02-22 16:31
  • 更新:2021-02-22 16:31
  • 阅读:949

子组件上报$emit事件方法,父组件方法触发后,改属性,为啥还是会报避免直接改变属性,因为每当父组件重新渲染时,该值将被覆盖

分类:uni-app

父组件

<template>  

    <view >  

        <coinPopup :popupShow="coinPopupShow" :coin_info="coinTypeInfo"  @closeMixedCurrencyClick="closeMixedCurrencyClick"></coinPopup>  

    </view>  

</template>  

<script>  
    import wybSlideListener from '@/components/wyb-slide-listener/wyb-slide-listener.vue'  
    import coinPopup from "./popup.vue"   

    export default {  
            components:{  
                summaryTable,mixCoinTable,coinPopup  
            },  
            data() {  
                return {  
                    coinTypeInfo:{},  
                    coinPopupShow:false,  
                }  
            },  
            methods: {  
                addMixedCurrencyClick:function(show){  
                     this.coinPopupShow=true;  
                    console.log(this.coinPopupShow);  
                },  
                closeMixedCurrencyClick:function(show){  
                     this.coinPopupShow=false;  
                    console.log(this.coinPopupShow);  
                },  
                getcoinPopup:function(){  
                    return this.coinPopupShow;  
                }  

            }  

        }  

</script>  

<style scoped lang="scss">  

</style>  

子组件:


<template>  
    <u-popup   
    v-model="popupShow"   
    width="90%"   
    close-icon-size="40"  
    :custom-style="customStyle"  
    mode="center"   
    :mask-custom-style="maskCustomStyle"  
    :closeable="true"  
    @close="closePopup()"  
    >  
        <view style="width: 90%;margin: 5%;">  
            <h3>{{getTitle()}}</h3>  

        </view>  
    </u-popup>  
</template>  

<script>  

    export default {  
        props:{  
            coin_info:{  
                type: Object,  
                default () {  
                    return {};  
                }  
            },  
            item:{},  
            popupShow:{  
                type: Boolean,  
                default: false  
            },  
        },  
        data() {  
            return {  

                maskCustomStyle:{  
                    background: 'rgba(0, 0, 0, 0.1)'  
                },  

                customStyle:{  

                }  
            }  
        },  
        computed: {  

        },  
        onShow() {  

        },  
        created() {  

        },  
        methods: {  
            getTitle(){  
                if(this.coin_info.coin_type === 'all'){  
                    return this.item.quantity+this.coin_info.coin;  
                }else{  
                    return this.coin_info.coin_name+this.coin_info.coin;  
                }  
            },  
            closePopup(){  
                this.$emit('closeMixedCurrencyClick',{coinPopup:false});  
            }  
        }  
    }  
</script>  

<style>  
</style>  
2021-02-22 16:31 负责人:无 分享
已邀请:

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