[Bug] this.config[col] is undefined

本文介绍了解决EasyUI中autoExpandColumn属性导致的问题的方法。通过为该属性所在的ColumnModel定义添加id属性,可以有效地解决表格列的展开问题。

解决办法:
给autoExpandColumn对应的属性在ColumnModel中的定义加个id属性,如下:
{id:'name',header: "name",width: 75, sortable: true, dataIndex: 'name'},

<template> <view> <u-row> <u-search v-model="keyword" @focus="active != 3 && tabChange(3)" @custom="tabChange(3)"></u-search> <view @click="tabChange(0)">推荐</view> <view @click="tabChange(1)">更新</view> </u-row> <view> <template v-if="!loading"> <u-row style="flex-wrap: wrap;" v-if="active == 0"> <u-col span="4" v-for="(item , index) in recommendList" :key="item.id"> <view class="bg"> <u-row style="flex-wrap: wrap;"> <u-col span="3"> <u-image :src="`${baseUrl}${item.appIcon}`" height="50rpx" width="50rpx"></u-image> </u-col> <u-col span="9"> <u-text :text="item.appName" bold size="30"></u-text> <u-text :text="item.appDescription" lines="2"></u-text> </u-col> </u-row> <u-row> <u-col span="3"> <u-button size="mini" :loading="downloadingAppIds.includes(item.id)" :text="downloadingAppIds.includes(item.id) ? '' : getAppStatus(item , installedAppList)" :color="getAppStatus(item , installedAppList , true)" :disabled="getAppStatus(item , installedAppList) == '已安装'" @click="handleDownload(item , getAppStatus(item , installedAppList))"></u-button> </u-col> </u-row> </view> </u-col> </u-row> <u-text text="本周热门" bold size="30" v-if="active == 0"></u-text> <u-row style="flex-wrap: wrap;"> <u-col span="4" v-for="(item , index) in appList" :key="item.id"> <u-row> <u-col span="3"> <u-image :src="`${baseUrl}${item.appIcon}`" height="50rpx" width="50rpx"></u-image> </u-col> <u-col span="7"> <u-text :text="item.appName" size="30"></u-text> </u-col> <u-col span="2"> <u-button size="mini" :loading="downloadingAppIds.includes(item.id)" :text="downloadingAppIds.includes(item.id) ? '' : getAppStatus(item , installedAppList)" :color="getAppStatus(item , installedAppList , true)" :disabled="getAppStatus(item , installedAppList) == '已安装'" @click="handleDownload(item , getAppStatus(item , installedAppList))"></u-button> </u-col> </u-row> <u-row> <u-col span="6"> <u-text :text="'发布版本:' + item.appVersion"></u-text> </u-col> <u-col span="6"> <u-text :text="'下载次数' + (item.downloadCount || 0)"></u-text> </u-col> </u-row> </u-col> </u-row> </template> </view> </view> </template> <script> export default { data() { return { baseUrl: uni.$u.http.config.baseURL, loading: true, recommendList: [], appList: [], downloadingAppIds: [], installedAppList: [], keyword: '', active: 0 } }, onShow(){ this.getApplicationMarketList() }, created() { this.getApplicationMarketList() }, methods: { getAppList(){ return new Promise((resolve , reject) => { // #ifdef APP-PLUS plus.android.importClass('java.util.ArrayList') plus.android.importClass('android.content.pm.PackageInfo') plus.android.importClass('android.content.pm.PackageManager') let MainActivity = plus.android.runtimeMainActivity() let PackageManager = MainActivity.getPackageManager() let pinfo = plus.android.invoke(PackageManager , 'getInstalledPackages' , 0) if(pinfo != null){ let apklist = [] for(let i = 0; i < pinfo.size(); i++){ let pkginfo = pinfo.get(i) let issysapk = ((pkginfo.plusGetAttribute('applicationInfo').plusGetAttribute( 'flags') & plus.android.importClass('android.content.pm.ApplicationInfo') .FLAG_SYSTEM) != 0) ? true : false if(issysapk == false){ const apkinfo = { packageName: pkginfo.plusGetAttribute('packageName'), versionName: pkginfo.plusGetAttribute('versionName') } apklist.push(apkinfo) } } resolve(apklist) }else{ reject([]) } // #endif // #ifndef APP-PLUS resolve([]) // #endif }) }, async getApplicationMarketList(){ this.loading = true this.installedAppList = await this.getAppList() uni.$u.http.get('/control/app/list' , {params: {appName : this.keyword}}).then(res => { this.appList = res.rows }).then(() => { if(this.active == 0){ this.recommendList = this.appList.filter(item => item.isRecommended).slice(0 , 3) uni.$u.http.get('/control/topic/list').then(res => { this.appList = res.rows[0].appList }) } if(this.active == 1 && this.installedAppList.length){ this.appList = this.appList.filter(item => { const app = this.installedAppList.find(app => app.packageName === item.appPackageName) if(app){ return item.appVersion > app.versionName } return false }) } }) this.loading = false }, downAndInstallApp(path){ return new Promise((resolve , reject) => { // #ifdef APP-PLUS uni.showToast({ title: '开始下载', icon: 'none' }) uni.downloadFile({ url: `${this.baseUrl}${path}`, success(result){ plus.runtime.install(result.tempFilePath , {force: true,}) resolve(result.statusCode) } }) // #endif // #ifndef APP-PLUS uni.showToast({ title: '请在APP中打开', icon: 'none' }) // #endif }) }, async handleDownload(item , status){ // #ifdef APP-PLUS this.downloadingAppIds.push(item.id) // #endif const result = await this.downAndInstallApp(item.appUrl) if(result == 200){ this.downloadingAppIds = this.downloadingAppIds.filter(id => id !== item.id) uni.$u.http.post('/control/record' , {appId: item.id}).then(() => { this.getApplicationMarketList() }) if(status == '更新'){ await uni.$u.http.put(`/control/app?id=${item.id}&appVersion=${parseFloat(item.appVersion) + 0.01}`) } } }, getAppStatus(item , installedAppList , color = false){ const app = installedAppList.find((app) => app.packageName === item.appPackageName) if(app){ if(color){ return item.appVersion > app.versionName ? 'blue' : 'gray' } return item.appVersion > app.versionName ? '更新' : '已安装' } if(color){ return 'black' } return '下载' }, tabChange(index){ this.active = index this.appList = [] this.getApplicationMarketList() } } } </script> <style scoped> .bg{ background: url('@/static/market/card_bg1.png') no-repeat; } </style> <template> <view> <u-row> <u-search v-model="keyword" @focus="active != 3 && tabChange(3)" @custom="tabChange(3)"></u-search> <view @click="tabChange(0)">推荐</view> <view @click="tabChange(1)">更新</view> </u-row> <template v-if="!loading"> <u-row style="flex-wrap: wrap;" v-if="active == 0"> <u-col span="4" v-for="(item , index) in recommendList" :key="item.id"> <view class="bg"> <u-row style="flex-wrap: wrap;"> <u-col span="3"> <u-image :src="`${baseUrl}${item.appIcon}`" height="50rpx" width="50rpx"></u-image> </u-col> <u-col span="9"> <u-text :text="item.appName" bold size="30"></u-text> <u-text :text="item.appDescription" ></u-text> </u-col> </u-row> <u-row> <u-col span="3"> <u-button :loading="downloadingAppIds.includes(item.id)" :text="downloadingAppIds.includes(item.id) ? '' : getAppStatus(item , installedAppList)" :color="getAppStatus(item , installedAppList , true)" :disabled="getAppStatus(item , installedAppList) == '已安装'" @click="handleDownload(item , getAppStatus(item , installedAppList))"></u-button> </u-col> </u-row> </view> </u-col> </u-row> <u-text text="本周热门" bold size="30" v-if="active == 0"></u-text> <u-row> <u-col span="4" v-for="(item , index) in appList" :key="item.id"> <u-row style="flex-wrap: wrap;"> <u-col span="3"> <u-image :src="`${baseUrl}${item.appIcon}`" height="50rpx" width="50rpx"></u-image> </u-col> <u-col span="6"> <u-text :text="item.appName" bold size="30"></u-text> </u-col> <u-col span="2"> <u-button :loading="downloadingAppIds.includes(item.id)" :text="downloadingAppIds.includes(item.id) ? '' : getAppStatus(item , installedAppList)" :color="getAppStatus(item , installedAppList , true)" :disabled="getAppStatus(item , installedAppList) == '已安装'" @click="handleDownload(item , getAppStatus(item , installedAppList))"></u-button> </u-col> </u-row> <u-row> <u-text :text="'发布版本:' + item.appVersion"></u-text> <u-text :text="'下载次数:' + (item.downloadCount || 0)"></u-text> </u-row> </u-col> </u-row> </template> </view> </template> <script> export default { data() { return{ baseUrl: uni.$u.http.config.baseURL, loading: true, appList: [], recommendList: [], installedAppList: [], downloadingAppIds: [], keyword: '', active: 0 } }, onShow(){ this.getApplicationMarketList() }, created() { this.getApplicationMarketList() }, methods: { getAppList(){ return new Promise((resolve , reject) => { // #ifdef APP-PLUS plus.android.importClass('java.util.ArrayList') plus.android.importClass('android.content.pm.PackageInfo') plus.android.importClass('android.content.pm.PackageManager') let MainActivity = plus.android.runtimeMainActivity() let PackageManager = MainActivity.getPackageManager() let pinfo = plus.android.invoke(PackageManager , 'getInstalledPackages' , 0) if(pinfo != null){ let apklist = [] for(let i = 0; i < pinfo.size(); i++){ let pkginfo = pinfo.get(i) let issysapk = ((pkginfo.plusGetAttribute('applicationInfo').plusGetAttribute( 'flags') & plus.android.importClass('android.content.pm.ApplicationInfo') .FLAG_SYSTEM) != 0) ? true : false if(issysapk == false){ const apkinfo = { packageName: pkginfo.plusGetAttribute('packageName'), versionName: pkginfo.plusGetAttribute('versionName') } apklist.push(apkinfo) } } resolve(apklist) }else{ reject([]) } // #endif // #ifndef APP-PLUS resolve([]) // #endif }) }, async getApplicationMarketList(){ this.loading = true this.installedAppList = await this.getAppList() uni.$u.http.get('/control/app/list' , {params: {appName: this.keyword}}).then(res => { this.appList = res.rows }).then(() => { if(this.active == 0){ this.recommendList = this.appList.filter(item => item.isRecommended).slice(0 , 3) uni.$u.http.get('/control/topic/list').then(res => { this.appList = res.rows[0].appList }) } if(this.active == 1 && this.installedAppList.length){ this.appList = this.appList.filter(item => { const app = this.installedAppList.find(app => app.packageName === item.appPackageName) if(app){ return item.appVersion > app.versionName } return false }) } }) this.loading = false }, downAndInstallApp(path){ return new Promise((resolve , reject) => { // #ifdef APP-PLUS uni.showToast({ title: '开始下载', icon: 'none' }) uni.downloadFile({ url: `${this.baseUrl}${path}`, success(result){ plus.runtime.install(result.tempFilePath , {force: true}) resolve(result.statusCode) } }) // #endif // #ifndef APP-PLUS uni.showToast({ title: '请在APP中打开', icon: 'none' }) // #endif }) }, async handleDownload(item , status){ // #ifdef APP-PLUS this.downloadingAppIds.push(item.id) // #endif const result = await this.downAndInstallApp(item.appUrl) if(result == 200){ this.downloadingAppIds = this.downloadingAppIds.filter(id => id !== item.id) uni.$u.http.post('/control/record' , {appIds: item.id}).then(() => { this.getApplicationMarketList() }) if(status == '更新'){ await uni.$u.http.put(`/control/app?id=${item.id}&appVersion=${parseFloat(item.appVersion) + 0.01}`) } } }, getAppList(item , installedAppList , color = false){ const app = installedAppList.find(app => app.packageName === item.appPackageName) if(app){ if(color){ return item.appVersion > app.versionName ? 'blue' : 'gray' } return item.appVersion > app.versionName ? '更新' : '已安装' } if(color){ return 'black' } return '下载' }, tabChange(index){ this.active = index this.appList = [] this.getApplicationMarketList() } } } </script> <style> </style>请对比两段代码的不同,我不希望也拒绝你的修改,只需要帮我找出两段代码不一样并导致bug的地方,不要找一些无关紧要的样式不同
最新发布
10-19
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值