Bootstrap

uniapp:图片/文件预览,截取图片路径,展示图片名称

previewImage(e) {
				var that = this
				that.imageUrl = that.risun.utils.dealImg(e)
				let index = that.imageUrl.lastIndexOf('.')
				let filename = that.imageUrl.slice(0, index) && index !== -1 ? that.imageUrl
					.slice(index) : ''
				console.log(filename)
				if (filename == '.png' || filename == '.jpeg' || filename == '.bmp' ||
					filename == '.psd' || filename == '.jpg') {
					that.current.push(that.imageUrl)
					uni.previewImage({
						current: index,
						urls: that.current
					})
				} else {
					uni.downloadFile({
						url: that.imageUrl, //文件链接
						success: function(res) {
							var filePath = res.tempFilePath;
							console.log(res)
							uni.openDocument({
								filePath: filePath,
								showMenu: true,
								success: function(res) {
									console.log('打开文档成功', res);
								}
							});
						}
					});
				}
			},

截取路径

let fileName = item.split('/').pop().split('_').shift()
;