问题发现:在一个tabs切换数据的过程中,发现接口并未返回数据,但是确有一个空白占位数据(如图1)

正确的情况应该为图2显示

组件1里面进行了数据长度判断,按理来说,返回的数据长度是为0的,应该显示为图2的,结果却为图1

// 条件为数据大于0才显示0">    ...此处代码省略     无图片默认展示图 

于是我试着把它的数据打印出来发现数据居然是有长度的,不过数据里面的不是数据,而是报错信息

TypeError: ‘caller’, ‘callee’, and ‘arguments’ properties may not be accessed on strict mode func

于是我找到了我的赋值操作数据已经查看报错检查原因

      getcouponAreaList() {            let area = this.currentTabs " />

​​​​​​​

解决方式1:将for in 换成for of

看到这个报错,哪怕不是for in 可能也是用的方法与严格模式冲突,也可以尝试使用别的方法来遍历

       //用券专区        getcouponAreaList() {            let area = this.currentTabs ? 'coupon' : 'discount';            this.loading = true;            this.$store            .dispatch('getDiscountArea', { ...this.postData, do: area })            .then((res) => {            const str = []            for (const i of res.data.data) {             str.push(i);            }            this.AreaList = str            this.list = res.data;            this.loading = false;            });        },

解决方式2:关闭严格模式

步骤一:npminstallbabel-plugin-transform-remove-strict-mode

步骤二:在.bablerc文件中加入"plugins":["transform-remove-strict-mode"]

不过还是建议使用第一种方法,简单快捷