帖子
帖子
用户
博客
课程
显示全部楼层
10
帖子
0
勋章
187
Y币

[YonStudio] 用组件引入就会报错,单独写就没问题是什么原因

[复制链接]
发表于 2023-5-30 16:43:10
TypeError: Cannot read property 'concat' of undefined
不修改代码的情况下,把这个封装成组件,真机预览,就会报错,单独拿出来就没事,是什么原因

<template>
    <grid-view id="gridView" class="main" column-count="2" aspect-ratio="1" inset="10" scroll-y enable-back-to-top onscrolltolower={this.onscrolltolower}>
        <cell class="cell" onclick={this.itemClick}>
            <text class="title">{item.title}</text>
        </cell>
        <list-footer class="footer">
            <text>加载中...</text>
        </list-footer>
    </grid-view>
</template>
<script>
export default {
    name: 'zyh-operation',
    methods:{
        apiready() {
            this.initData(false);
        },
        initData(loadMore) {
            var that = this;
            var skip = that.dataList?that.dataList.length:0;
            var dataList = [];
            for (var i=0;i<99;i++) {
                dataList[i] = {
                    title: '项目' + (i + skip)
                };
                // 瀑布流效果
                dataList[i].itemHeight = Math.floor(200 + Math.random()*50);
            }
            var gridView = document.getElementById('gridView');
            if (loadMore) {
                that.dataList = that.dataList.concat(dataList);
                gridView.insert({
                    data: dataList
                });
            } else {
                that.dataList = dataList;
                gridView.load({
                    data: dataList
                });
            }
        },
        onscrolltolower() {
            this.initData(true);
        },
        itemClick(e) {
            api.alert({
                msg: '点击了项:' + e.currentTarget.index
            });
        }
    }
}
</script>
<style>
    .main {
        width: 100%;
        height: 100%;
    }
    .cell {
        justify-content: center;
        align-items: center;
        background-color: #5cdfdc;
    }
    .title {
        font-weight: bold;
        color: #000;
    }
    .footer {
        justify-content: center;
        align-items: center;
        height: 44px;
    }
</style>




380
帖子
4
勋章
6
Y币
您好,找到问题原因了吗?
10
帖子
0
勋章
187
Y币
技术咨询-F · 2023-5-31 11:42您好,找到问题原因了吗?

没有,同样的代码,封装成组件就有问题了,引入方法又没问题,这让我去哪解决啊
380
帖子
4
勋章
6
Y币
小暧 · 2023-5-31 11:55没有,同样的代码,封装成组件就有问题了,引入方法又没问题,这让我去哪解决啊

全量同步测试看看
10
帖子
0
勋章
187
Y币
技术咨询-F · 2023-5-31 13:44全量同步测试看看

不行,依旧会报错
您需要登录后才可以回帖 登录

本版积分规则