帖子
帖子
用户
博客
课程
显示全部楼层
55
帖子
2
勋章
580
Y币

[BUG] avm 中v-show 组件中的控制显示不起作用

[复制链接]
发表于 2023-6-6 02:55:21
在组件中用v-show 控制显示的view,无论用 computed 计算方法 还是用 methods 方法 还是用主页面赋值  都会是一个固定值  true
computed  中输出多次都是false 最后会多一次输出 输出空

win页面代码 与 组件代码 贴出来了,那位大佬帮忙看看



<template>
    <safe-area class="page">
        <!-- header -->
        <hot-common-header title="确认订单" showtype="true"/>

        <scroll-view class="scroll-view" scroll-y>

            <!-- 地址 -->
            <orderpush-address-page :addressObj="addressDefault" :isShowAddress="is_show_address" onchildGoToAddress="fatherGoToAddress"/>

            <!-- 商品 -->
            <!-- <orderpush-goods-list :storeGoodsObj="storeGoods_obj"/> -->

            <!-- 优惠券 -->
            <!-- <orderpush-coupon-page couponMoney="0"/> -->
            
        </scroll-view>

        <!-- footer 提交订单 -->
        <!-- <orderpush-footer-page onchildgenerateOrder="fatherGenerateOrder" :countLovePriceMoneyStr="countLovePriceMoney" :countPriceMoneyStr="countPriceMoney"/> -->

    </safe-area>
</template>
<script>
import '../components/hot-common-header.stml';
import '../components/order-component/orderpush-address-page.stml';
// import '../components/order-component/orderpush-goods-list.stml';
// import '../components/order-component/orderpush-coupon-page.stml';
// import '../components/order-component/orderpush-footer-page.stml';

import jiuTu from '../script/jiutu';
import routing from '../script/routing';
export default {
    name: 'orderpush',
    apiready() {
        var _this = this;
        //如监听选择地址事件
        api.addEventListener({
            name: 'selectAddressEvent'
        }, function(ret, err) {
            if(JSON.stringify(ret.value) != "{}" && ret.value != undefined){
                _this.data.addressDefault = ret.value;
                _this.data.is_show_address = true;
            }
        });
        _this.data.goodsArrParam = api.pageParam.goodsArrParam || [];
        if(_this.data.goodsArrParam.length < 1 ){
            api.closeWin();
        }
        _this.init();
     },
    data() {
        return {
            goodsArrParam: [],
            addressDefault: {},
            storeGoods_obj:{},
            countPriceMoney:"",
            countLovePriceMoney:"",
            is_show_address:false,
        };
    },
    methods: {
        init(){
            let _this = this;
            //数据加载中
            jiuTu.loadFrame();
            //请求数据
            let bodyJson = { goods_info: JSON.stringify(_this.data.goodsArrParam) };
            jiuTu.jsonRequest(routing.getRoute("orderConfirmUrl"), "GET", true, bodyJson, function (ret, err) {
                if (ret && JSON.stringify(ret) != "{}") {
                    if(ret.hasOwnProperty("data")){
                        _this.data.storeGoods_obj = ret.data;
                        _this.data.countPriceMoney = ret.total_price;
                        _this.data.countLovePriceMoney = ret.total_love_price;
                        _this.data.addressDefault = ret.address_default;
                        _this.data.is_show_address = JSON.stringify(ret.address_default) != "{}" ? true : false;
                    }
                } else {
                    jiuTu.errTip(err);
                }
                //关闭数据加载中
                jiuTu.closeLoadFrame();
            });
        },
        fatherGoToAddress(){
            let token = jiuTu.token();
            if(token){
                api.openWin({
                    name: 'address',
                    url:'address.stml'
                });
            }
        },
        fatherGenerateOrder(){
            let token = jiuTu.token();
            if(token){
                api.openWin({
                    name: 'orderpushpay',
                    url:'orderpushpay.stml'
                })
            }
        }
    }
};
</script>
<style>
.page {
    height: 100%;
    background: #fff;
}
/*  */
.scroll-view {
    flex: 1;
    background: #EAEAEA;
    padding: 0 6px;
}
</style>





<template>
    <view @click="goToAddress">
        <view class="address" v-show="!this.props.isShowAddress">
            <image class="address-img" src="../icon/add.png" mode="widthFix" />
            <text class="address-name">新增收获地址</text>
        </view>

        <view class="addressinfo" v-show="this.props.isShowAddress">
            <view class="address_1">
                <text class="address-name1">{{addressStrFn}}</text>
                <text class="address-name">&gt;</text>
            </view>
            <view class="address_2">
                <text class="address-name2 ">{{addressStrNameFn}}</text>
                <text class="address-name2">{{addressStrPhoneFn}}</text>
            </view>
        </view>
    </view>
</template>
<script>
export default {
    name: 'orderpush-address-page',
    apiready() {//like created

    },
    installed() {

    },
    props: {
        addressObj: Object,
        isShowAddress: Boolean,
    },
    data() {
        return {

        }
    },
    computed: {
        addressStrFn: function () {
            let _this = this;
            if (JSON.stringify(_this.props.addressObj) != "{}" && _this.props.addressObj != undefined) {
                return this.props.addressObj.province + this.props.addressObj.city + this.props.addressObj.area;
            }
            return "";
        },
        addressStrNameFn: function () {
            let _this = this;
            if (JSON.stringify(_this.props.addressObj) != "{}" && _this.props.addressObj != undefined) {
                    return _this.props.addressObj.name;
                }
            return "";
        },
        addressStrPhoneFn: function () {
            let _this = this;
            if (JSON.stringify(_this.props.addressObj) != "{}" && _this.props.addressObj != undefined) {
                    return _this.props.addressObj.phone;
                }
            return "";
        }
    },
    methods: {
        goToAddress() {
            let detail = {};
            this.fire('childGoToAddress', detail);
        },
    }
}
</script>
<style>
.address {
    height: 60px;
    background: #fff;
    border-radius: 8px;
    flex-direction: row;
    align-items: center;
    margin: 10px 7px 10px 7px;
}

.address-img {
    width: 18px;
    margin: 5px 10px 5px 15px;
}
.address-name1 {
    flex: 1;
    font-size: 16px;
    font-weight: 500;
    line-height: 20px;
    color: #000;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.address-name2 {
    font-size: 12px;
    font-weight: 300;
    line-height: 20px;
    color: rgb(99, 93, 93);
    margin-right: 5px;
}

.addressinfo {
    height: 80px;
    background: #fff;
    border-radius: 8px;
    align-items: center;
    margin: 10px 7px 10px 7px;
    padding: 8px 15px;
    justify-content: space-around;
}
.address_1 {
    width: 100%;
    height: 20px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}
.address_2 {
    width: 100%;
    height: 20px;
    flex-direction: row;
}
</style>






技术咨询-F
380
帖子
4
勋章
6
Y币
最佳答案
https://community.yonyou.com/thread-230056-1-1.html
380
帖子
4
勋章
6
Y币
您需要登录后才可以回帖 登录

本版积分规则