uni.previewImage({urls: this.file.map(i => i.url ),current: idx})
async handleSubmit() {if (this.submiting) {return}this.submiting = truetry {let error = ''if (!this.form.landName.trim()) {error = '请输入地块名称'} else if (!this.form.plantType) {error = '请选择种植/养殖类型'} else if (!this.form.plantCategory) {error = `请选择${this.typeLabel}品类`} else if (!this.form.plantVarieties.trim()) {error = `请输入${this.typeLabel}品种`} else if (!this.form.plantQuantity || !(this.form.plantQuantity > 0)) {error = `请输入${this.typeLabel}数量`} else if (!/^\d{1,4}(\.\d{1,2})?$/.test(this.form.plantQuantity)) {error = `请输入最多两位小数,最多四位数的${this.typeLabel}数量`} else if (!this.form.cropsImgs || this.form.cropsImgs.length < 5) {error = this.plantType === '2' ? '请上传养殖动物图片' : '请上传农作物图片'}if (error) {uni.showToast({ icon: 'none', title: error })return}await serviceAPI.saveBlock({ ...this.form, farmerId: this.authInfo.farmerId })uni.showToast({ icon: 'none', title: '保存成功' })uni.navigateBack()} catch (error) {uni.showToast({ icon: 'none', title: error.message })throw error} finally {this.submiting = false}},
:class="{'active':(current === idx)}"
代码格式化(全部格式化、局部格式化)
:::info
yarn lint —write
:::

yarn prettier --list-different src/pages --write


