1.一个数组中的数据是否完全包含另一个数组中的数据
component.componentProps.value.every(value => ruleList.masterFieldDependencies.includes(value)
2.事件总线
发送
this.$bus.$emit(
'change-data-drop',
ruleList.valueBelongsToTheField,
ruleList.mayflyKey
)
打开
在mounted之中调用方法
this.$bus.$on('cp-change-dimission-reason', options => {
const { name = '' } = options
this.name = name
this.data.value = options
})
注意在打开的页面销毁不然会多次调用
destroyed() {
this.$bus.$off('cp-change-dimission-reason')
}
3.响应拦截器
this.form = new Proxy(this.form, {
set: (obj, prop, value) => {
// 拦截templateType变更
if ((
prop === 'templateType' ||
prop === 'applyFormId' ||
prop === 'approvalFormId' ) &&
obj[prop] !== value) {
this.changeTemplate(value,prop)
.then(res => {
res && (obj[prop] = value)
})
} else {
obj[prop] = value
}
return true
}
})
4.全局组件的注册
import Vue from 'vue'
// 注册组件
let components = [
require.context('./configComponent', true, /\.vue$/),
require.context('./baseComponent', true, /\.vue$/)
]
components.forEach(component => {
component.keys().forEach(key => {
Vue.component(component(key).default.name, component(key).default)
})
})