1***@qq.com
1***@qq.com
  • 发布:2018-12-09 20:38
  • 更新:2019-10-26 11:50
  • 阅读:1673

【报Bug】Chrome调试环境,动态加载picker的range数据会报错

分类:uni-app

Chrome调试环境,动态加载picker的range数据会报错

index.umd.min.js:1 [system] errorHandler TypeError: Cannot read property 'call' of undefined
at Watcher.getAndInvoke (vue.runtime.esm.js:3316)
at Watcher.run (vue.runtime.esm.js:3296)
at flushSchedulerQueue (vue.runtime.esm.js:3031)
at Array.<anonymous> (vue.runtime.esm.js:1888)
at flushCallbacks (vue.runtime.esm.js:1809) VueComponent {_uid: 65, _isVue: true, $options: {…}, _renderProxy: Proxy, _self: VueComponent, …} callback for watcher "range"

2018-12-09 20:38 负责人:无 分享
已邀请:
DCloud_UNI_GSQ

DCloud_UNI_GSQ

请提供一个复现问题的demo

  • l***@qq.com

    在官方的例子里加一句化就能复现 bindPickerChange: function(e) {

    console.log('picker发送选择改变,携带值为', e.target.value)

    this.index = e.target.value

    this.array = ['国', '巴', '日'];

    },

    2019-01-12 15:39

Viccy

Viccy

同问,虽然结果显示出来了,但是console有错误

l***@qq.com

l***@qq.com - OK啦

复现的例子

<template>  
    <view>  
        <page-head :title="title"></page-head>  
        <view class="uni-title uni-common-pl">地区选择器</view>  
        <view class="uni-list">  
            <view class="uni-list-cell">  
                <view class="uni-list-cell-left">  
                    当前选择  
                </view>  
                <view class="uni-list-cell-db">  
                    <picker @change="bindPickerChange" :value="index" :range="array">  
                        <view class="uni-input">{{array[index]}}</view>  
                    </picker>  
                </view>  
            </view>  
        </view>  

        <view class="uni-title uni-common-pl">时间选择器</view>  
        <view class="uni-list">  
            <view class="uni-list-cell">  
                <view class="uni-list-cell-left">  
                    当前选择  
                </view>  
                <view class="uni-list-cell-db">  
                    <picker mode="time" :value="time" start="09:01" end="21:01" @change="bindTimeChange">  
                        <view class="uni-input">{{time}}</view>  
                    </picker>  
                </view>  
            </view>  
        </view>  

        <view class="uni-title uni-common-pl">日期选择器</view>  
        <view class="uni-list">  
            <view class="uni-list-cell">  
                <view class="uni-list-cell-left">  
                    当前选择  
                </view>  
                <view class="uni-list-cell-db">  
                    <picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange">  
                        <view class="uni-input">{{date}}</view>  
                    </picker>  
                </view>  
            </view>  
        </view>  
    </view>  
</template>  
<script>  
    export default {  
        data() {  
            const currentDate = this.getDate({  
                format: true  
            });  
            return {  
                title: 'picker',  
                array: ['中国', '美国', '巴西', '日本'],  
                index: 0,  
                date: currentDate,  
                time: '12:01'  
            }  
        },  
        computed: {  
            startDate() {  
                return this.getDate('start');  
            },  
            endDate() {  
                return this.getDate('end');  
            }  
        },  
        methods: {  
            bindPickerChange: function(e) {  
                console.log('picker发送选择改变,携带值为', e.target.value)  
                this.index = e.target.value  
                this.array = ['国', '巴', '日'];  
            },  
            bindDateChange: function(e) {  
                this.date = e.target.value  
            },  
            bindTimeChange: function(e) {  
                this.time = e.target.value  
            },  
            getDate(type) {  
                const date = new Date();  

                let year = date.getFullYear();  
                let month = date.getMonth() + 1;  
                let day = date.getDate();  

                if (type === 'start') {  
                    year = year - 60;  
                } else if (type === 'end') {  
                    year = year + 2;  
                }  
                month = month > 9 ? month : '0' + month;;  
                day = day > 9 ? day : '0' + day;  

                return `${year}-${month}-${day}`;  
            }  
        }  
    }  
</script>  

<style>  

</style>
y***@qq.com

y***@qq.com - 互联网极客 前端Vue 后端Java 微服务实践者

Uncaught TypeError: Cannot read property 'call' of undefined 总是报这个错误

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