使用场景:
当多个方法在不同的组件之中重复来回的使用的情况下,可以采用Vue的混入。
使用方法:
1、新建js文件,名字尽量可以区分不同的项目。
2、workorderCommon.js提取出公共的部分。
import xxx from '../../xxxxx';
export const channelCommon = {
data() {
return {
};
},
methods: {
},
created() {
},
};
export const classifyCommon = {
data() {
return {
};
},
methods: {
},
created() {
},
computed: {
},
};
3、.vue文件引入。
import { channelCommon, classifyCommon } from './workorderCommon.js';
export default {
mixins: [channelCommon, classifyCommon],
data() {
.......
}
}