- 不同选项之前需要留有空行,同一个选项,内容之间不用留空行分隔(如:methods)。
- 注意选项的声明顺序,先声明外部传入的数据(如:props),再声明内部数据(如:data、computed、watch)
<template>
<div class="el-cascader">
...
</div>
</template>
<script>
import Clickoutside from 'element-ui/src/utils/clickoutside';
const PopperMixin = {
props: {
placement: {
type: String,
default: 'bottom-start'
}
},
methods: {},
data: { return {...} },
beforeDestroy: () => {}
};
export default {
name: 'ElCascader', // 组件名需大驼峰命名
directives: { Clickoutside },
mixins: [PopperMixin, Emitter],
inject: {
elForm: {
default: ''
}
},
components: {},
props: {},
data() {
return {
list: []
...
}
},
computed: {
isDisabled() {
return this.disabled || (this.elForm || {}).disabled;
},
},
watch: {
presentText(newVal, oldVal) {
this.inputValue = newVal;
},
options: {
handler: function() {
this.$nextTick(this.computePresentContent);
},
deep: true
},
},
mounted() {},
beforeDestroy() {},
methods: {
handleDropdownLeave() {
...
},
toggleDropDownVisible() {
...
}
}
}
</script>
<style lang="scss" scoped>
</style>