4***@qq.com
4***@qq.com
  • 发布:2019-01-21 09:12
  • 更新:2019-01-21 14:41
  • 阅读:1749

同样的代码 百度小程序可以显示数据 为什么微信小程序显示不了

分类:uni-app

代码如下

<template>  
    <view class="content">  
        <image class="top_back_img" src="../../static/user-setting/set-top-bg.png" mode="aspectFit"></image>  
        <view class="top">  
            <view class="circle">  
                <image class="head" v-bind:src="photo" mode="widthFix"></image>  
            </view>  
            <view class="top-texts">  
                <text class="name">{{userName}}</text>  
                <image class="set-top-hr" src="../../static/user-setting/set-top-hr.png" mode=""></image>  
                <text class="depart">{{office}}</text>  
                <view>  
                    <text>{{mobile}}</text>  
                </view>  
            </view>  
            <view class="top-changeInfo">  
                <text>修改</text>  
            </view>  
        </view>  

        <!-- 下半部分 -->  
        <view class="index">  
            <view class="cell" @click="changeGray">  
                <view class="cell-left">  
                    <image class="cell_icon" src="../../static/user-setting/account.png"></image>  
                    <text class="cell-text">修改密码</text>  
                </view>  
                <view class="cell-right">  
                    <image class="right-arrow" src="../../static/user-setting/right-arrow.png"></image>  
                </view>  
            </view>  

            <view class="cell" @click="changeGray">  
                <view class="cell-left">  
                    <image class="cell_icon" src="../../static/user-setting/account.png"></image>  
                    <text class="cell-text">当前版本</text>  
                </view>  
                <view class="cell-right">  
                    <image class="right-arrow" src="../../static/user-setting/right-arrow.png"></image>  
                </view>  
            </view>  

            <view class="cell" @click="changeGray">  
                <view class="cell-left">  
                    <image class="cell_icon" src="../../static/user-setting/account.png"></image>  
                    <text class="cell-text">检查更新</text>  
                </view>  
                <view class="cell-right">  
                    <image class="right-arrow" src="../../static/user-setting/right-arrow.png"></image>  
                </view>  
            </view>  

            <view class="cell" @click="changeGray">  
                <view class="cell-left">  
                    <image class="cell_icon" src="../../static/user-setting/account.png"></image>  
                    <text class="cell-text">清除缓存</text>  
                </view>  
                <view class="cell-right">  
                    <image class="right-arrow" src="../../static/user-setting/right-arrow.png"></image>  
                </view>  
            </view>  

            <view class="cell" @click="changeGray">  
                <view class="cell-left">  
                    <image class="cell_icon" src="../../static/user-setting/account.png"></image>  
                    <text class="cell-text">关于</text>  
                </view>  
                <view class="cell-right">  
                    <image class="right-arrow" src="../../static/user-setting/right-arrow.png"></image>  
                </view>  
            </view>  

        </view>  

        <!-- 退出登录 -->  
        <!--        <view class="logout" style="width:80%;margin-top: 50upx;">  
            <button type="warn" @click="logout">退出登录</button>  
        </view> -->  
        <view class="logout" style="width:100%;margin-top: 50upx;">  
            <button v-if="!hasLogin" type="primary" class="primary" @tap="bindLogin">登录</button>  
            <button v-if="hasLogin" type="default" class="primary" @tap="bindLogout">退出登录</button>  
        </view>  
    </view>  
    <!--    <view class="content">  
        <view class="btn-row">  
            <button v-if="!hasLogin" type="primary" class="primary" @tap="bindLogin">登录</button>  
            <button v-if="hasLogin" type="default" @tap="bindLogout">退出登录</button>  
        </view>  
    </view> -->  

</template>  

<script>  
    import {  
        mapState,  
        mapMutations  
    } from 'vuex'  

    export default {  
        computed: {  
            ...mapState(['userInfo', 'basicIP','userName', 'hasLogin', 'forcedLogin'])  
        },  
        onLoad() {  
            this.mobile=this.userInfo["mobile"];  
            this.phone=this.userInfo["phone"],  
            this.email=this.userInfo["email"],  
            this.office=this.userInfo["office"]["name"],  
            this.company=this.userInfo["company"]["name"],  
            this.photo=this.basicIP+this.userInfo["photo"],  
            console.log(this.photo);  
            console.log(this.mobile);  
            console.log(this.office);  
        },  
        methods: {  
            ...mapMutations(['logout']),  
            data() {  
                return {  

                    mobile: "1234",  
                    phone: "",  
                    email:"",  
                    office: "",  
                    company:"",  
                    photo:"",  
                }  
            },  
            bindLogin() {  
                uni.navigateTo({  
                    url: '../login/login',  
                });  
            },  
            bindLogout() {  
                this.logout();  
                /**  
                 * 如果需要强制登录跳转回登录页面  
                 */  
                if (this.forcedLogin) {  
                    uni.reLaunch({  
                        url: '../login/login',  
                    });  
                }  
                this.bindLogin();  
            }  
        }  
    }  
</script>

{{mobile}}和{{office}}已正常赋值

2019-01-21 09:12 负责人:无 分享
已邀请:
Trust

Trust - 少说废话

不同小程序平台,还是有很大差异的。
上传个测试项目,并且补充下操作步骤,方便测试确认下,谢谢配合。

  • 4***@qq.com (作者)

    测试代码地址如下,直接clone

    https://gitee.com/wndayday/dev

    代码直接放在hbuilderx里:



    1. 用微信小程序运行

    2. 用百度小程序运行

    2019-01-21 14:46

4***@qq.com

4***@qq.com (作者) - 小码

测试代码地址如下,直接clone
https://gitee.com/wndayday/dev
代码直接放在hbuilderx里:

  1. 用微信小程序运行
  2. 用百度小程序运行

  • Trust

    代码不对呀,data 怎么声明到 methods 里面去了?

    2019-01-23 20:34

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