Gyon_Lars
Cythsic
2020-07-16 08:57

求大佬!!!uniapp数据更新延迟

  • vue.js

一个很简单的页面传参,用的是表单提交,但是提交之后跳转页面数据不更新,但是console打印出来数据是更新的。刚开始学这个,小白求一个原因和解决办法!!!

输入页面代码

姓名工号查询班次 {{index>-1?picker[index]:'选择查询班次'}} 开始日期 {{date1}} 截止日期 {{date2}} 重置 查询
    </view>
    </template>
    <script>
    var num='03124522';
 var usrName='test';
export default {
    data() {
        return {
            picker: ['上班', '下班'],
            index: -1,
            date1: "请选择",
            date2: "请选择",
            name: usrName,
            number: num,

        }
    },
    methods: {
        pickerChange(e) {
            this.index = e.detail.value
        },
        DateChange1(e) {
            this.date1 = e.detail.value
        },
        DateChange2(e) {
            this.date2 = e.detail.value
        },
        formSubmit: function(e) {
            console.log('form发生了submit事件,携带数据为:' + JSON.stringify(e.detail.value));
            var formdata = e.detail.value;
            //console.log(formdata.duty);
            uni.navigateTo({
                url: encodeURI('./new_file?name=' + usrName + '&number=' + num + '&duty=' + formdata.duty+'&startDate='+formdata.startDate+'&endDate='+formdata.endDate)
            })

        },
        formReset: function(e) {
            console.log('清空数据')
        },

    }
}


数据接收页面代码
<template>
    <div id="table">
        <table cellpadding="0" cellspacing="0">
            <thead>
                <tr>
                    <th width='50px'>工号</th>
                    <th width='50px'>姓名</th>
                    <th width='30px'>班次</th>
                    <th>查询时间</th>
                </tr>
            </thead>
            <tbody>
            <tr>
                    <td>{{number}}</td>
                    <td>{{name}}</td>
                    <td v-if="duty=0">上班</td>
                    <td else-if="duty=1">下班</td>
                    <td>{{start}} - {{end}}</td>
                </tr>
            </tbody>
        </table>

        <div class="add">
            <br>
            <navigator open-type="navigate" url="index">
                <button>返回</button>
            </navigator>
        </div>
        <br>
    </div>


</template>

<script>
    var arr = [];
    var name;
    var number;
    var duty;
    var startTime;
    var endTime
    export default {
        name: "tables1",
        data() {
            return {
            name:name,
                number:number,
                duty:duty,
                start:startTime,
                end:endTime,
            }
        },
        onLoad: function(options) {
            name = options.name;
            number = options.number;
            duty = options.duty;
            startTime=options.startDate;
            endTime=options.endDate;
            },
            }
        </script>
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答