We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
// 数据初始化 _initData () { getHomeData().then(response => { if (response.success) { // 给轮播组件 sowing_list赋值 this.sowing_list = response.data.list[0].icon_list; this.nav_list = response.data.list[2].icon_list; this.flash_sale_product_list = response.data.list[3].product_list; this.tabbar_all_product_list = response.data.list[12].product_list; this.isShowLoading = false // 给特色专区赋值 this.specialZone = response.data.special_zone; // 获取首页广告图 this.home_ad = response.data.home_ad.image_url; } }).catch(error => { console.log(error); });
The text was updated successfully, but these errors were encountered:
优化点一: 可以使用 async await 简化代码
优化点二: 可以使用 简化 数据结构 const data = response.data 简化代码
// 数据初始化 _initData async () { const response = await getHomeData(); if (response.success) { const data = response.data // 给轮播组件 sowing_list赋值 this.sowing_list = data.list[0].icon_list; this.nav_list = data.list[2].icon_list; this.flash_sale_product_list = data.list[3].product_list; this.tabbar_all_product_list = data.list[12].product_list; this.isShowLoading = false // 给特色专区赋值 this.specialZone = data.special_zone; // 获取首页广告图 this.home_ad = data.home_ad.image_url; } }
Sorry, something went wrong.
DuZhu: Right! Thanks a lot give me the code improve suggest.You can send pull requests for me.We maintain together.Thanks you~😁
No branches or pull requests
The text was updated successfully, but these errors were encountered: