From 16bd1b43bc3bba017759a2a7df26922954833e4e Mon Sep 17 00:00:00 2001 From: tianjiaxing Date: Wed, 18 Nov 2020 21:36:13 +0800 Subject: [PATCH] fixed: uni-form get vm $option bug --- src/components/uni-forms/uni-forms.vue | 53 +++++++++++++------------- src/pages/vue/goods-nav/goods-nav.vue | 14 +++++++ 2 files changed, 41 insertions(+), 26 deletions(-) diff --git a/src/components/uni-forms/uni-forms.vue b/src/components/uni-forms/uni-forms.vue index 00140285..4fa763b7 100755 --- a/src/components/uni-forms/uni-forms.vue +++ b/src/components/uni-forms/uni-forms.vue @@ -31,19 +31,20 @@ * @event {Function} submit 提交时触发 */ import Vue from 'vue' - Vue.prototype.binddata = function(name, value, formName) { + Vue.prototype.binddata = function(name, value, formName) { if (formName) { this.$refs[formName].setValue(name, value) } else { - let refName = null + let formVm for (let i in this.$refs) { - if (this.$refs[i] && this.$refs[i].$options.name === 'uniForms') { - refName = i + const vm = this.$refs[i] + if (vm && vm.$options && vm.$options.name === 'uniForms') { + formVm = vm break } } - if (!refName) return console.error('当前 uni-froms 组件缺少 ref 属性') - this.$refs[refName].setValue(name, value) + if (!formVm) return console.error('当前 uni-froms 组件缺少 ref 属性') + formVm.setValue(name, value) } } @@ -107,11 +108,11 @@ this.formTrigger = trigger }, value: { - handler(newVal) { + handler(newVal) { if (this.isChildEdit) { this.isChildEdit = false return - } + } this.childrens.forEach((item) => { if (item.name) { const formDataValue = newVal.hasOwnProperty(item.name) ? newVal[item.name] : null @@ -124,7 +125,7 @@ }, created() { let _this = this - this.childrens = [] + this.childrens = [] this.inputChildrens = [] this.formRules = [] this.init(this.rules) @@ -159,7 +160,7 @@ let example = this.childrens.find(child => child.name === name) if (!example) return null this.isChildEdit = true - value = this._getValue(example, value) + value = this._getValue(example, value) this.formData[name] = value example.val = value this.$emit('input', Object.assign({}, this.value, this.formData)) @@ -200,7 +201,7 @@ * 触发表单校验,通过 @validate 获取 * @param {Object} validate */ - validateCheck(validate) { + validateCheck(validate) { if (validate === null) validate = null this.$emit('validate', validate) }, @@ -259,11 +260,11 @@ [i]: fieldsValue[i] }, this.formData) if (resultData) { - example = this.childrens.find(child => child.name === resultData.key) - const inputComp = this.inputChildrens.find(child=>child.rename === example.name) - if(inputComp){ - inputComp.errMsg = resultData.errorMessage - } + example = this.childrens.find(child => child.name === resultData.key) + const inputComp = this.inputChildrens.find(child=>child.rename === example.name) + if(inputComp){ + inputComp.errMsg = resultData.errorMessage + } result.push(resultData) if (this.errShowType === 'undertext') { if (example) example.errMsg = resultData.errorMessage @@ -304,8 +305,8 @@ callback && typeof callback === 'function' && callback(result, invalidFields) if (promise && callback) { return promise - }else{ - return null + }else{ + return null } }, @@ -314,7 +315,7 @@ * 手动提交校验表单 * 对整个表单进行校验的方法,参数为一个回调函数。 */ - submit(callback) { + submit(callback) { // Object.assign(this.formData,formData) return this.validateAll(this.formData, 'submit', callback) }, @@ -394,14 +395,14 @@ } - + diff --git a/src/pages/vue/goods-nav/goods-nav.vue b/src/pages/vue/goods-nav/goods-nav.vue index 9f1f9796..04470891 100644 --- a/src/pages/vue/goods-nav/goods-nav.vue +++ b/src/pages/vue/goods-nav/goods-nav.vue @@ -89,4 +89,18 @@ /* #endif */ bottom: 0; } + + /* #ifdef H5 */ + @media screen and (min-width: 768px, max-width: 1425px) { + .swiper { + height: 630px; + } + } + @media screen and (min-width: 1425px) { + .swiper { + height: 830px; + } + } + /* #endif */ +