How to set the default picture when WeChat Mini Programs can't get the data?

problem description

I have a swiper child component, in which the picture is requested by the parent component and then passed to the child component. If the swiper is blank when the parent component is not requested, how to set a default image when the data is not available. SUNING has this effect

the environmental background of the problems and what methods you have tried

I can"t set it under the value property under properties.

related codes

/ / Please paste the code text below (do not replace the code with pictures)

imgUrls: {

  type: Object, 
  value: ["../img/bg_indexbanner.jpg","../img/bg_indexbanner.jpg"]
}

what result do you expect? What is the error message actually seen?

Picture description

Dec.21,2021

make request judgment. If the request fails, the default image array is returned. The request is successful but the array is empty. It also returns the default picture array


img tag with an onerror event


.

the picture component of your broadcast graph component must first have a default image src, and then when your parent component requests data successfully, replace the real image address with it.

< hr >
const app = getApp()

Page({
  data: {
    imglist: [
      'defaultURL',
      'defaultURL',
      'defaultURL',
    ]
  },
  onLoad: function () {
    this.getImg()
  },
  getImg(){
    wx.request({
      url: '',
      success: res => {
        const imglist = res.data.imgs
        this.setData({ imglist })
      }
    })
  }
})

can you try this?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3cc34-e88c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3cc34-e88c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?