const util = require('../../utils/util') //导入模块 Component({ options: { addGlobalClass: true, multipleSlots: true }, properties: { src: { type: String, value: '' }, width: { type: Number, value: 80 }, height: { type: Number, value: 80 }, imageList: { type: Array, value: [] } }, observers: { 'imageList': function () { for (let index = 0; index < this.data.imageList.length; index++) { if(!this.isPdfUrl(this.data.imageList[index])){ this.setData({ src: this.data.imageList[index] }) break } } if(util.isEmpty(this.data.src)){ this.setData({ src: this.data.imageList[0] }) } } }, methods: { isPdfUrl: function (url) { if (url && (url.indexOf('.pdf') >= 0 || url.indexOf('.PDF') >= 0)) { return true } return false } } })