html:
<el-form-item label="所属分类" prop="speconeclass"> <el-select v-model="topform.speconeclass" size="mini" placeholder="请选择一级分类"> <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" ></el-option> </el-select> <el-select v-model="topform.spectwoclass" size="mini" placeholder="请选择二级分类" ref="spectwoclass" > <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" ></el-option> </el-select> </el-form-item>
rules:
speconeclass: [
{ required: true, validator: this.checkFrequency, trigger: "change" }
]
methods:
//同时验证两个select框
checkFrequency(rule, value, callback) {
let spectwoclass = this.$refs.spectwoclass.value;
if (value && spectwoclass) {
callback();
} else {
callback(new Error("请选择一级分类和二级分类"));
}
},