|
[YonStudio]
用组件引入就会报错,单独写就没问题是什么原因
[复制链接]
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>
|
|