mirror of
https://github.com/youzan/vant.git
synced 2025-10-19 18:14:13 +00:00
[improvement] extract relation mixin
This commit is contained in:
@@ -2,34 +2,25 @@ import { use, isDef } from '../utils';
|
||||
import Cell from '../cell';
|
||||
import Icon from '../icon';
|
||||
import Popup from '../popup';
|
||||
import { ChildrenMixin } from '../mixins/relation';
|
||||
|
||||
const [sfc, bem] = use('dropdown-item');
|
||||
|
||||
export default sfc({
|
||||
mixins: [ChildrenMixin('vanDropdownMenu')],
|
||||
|
||||
props: {
|
||||
value: null,
|
||||
title: String,
|
||||
options: Array
|
||||
},
|
||||
|
||||
inject: ['vanDropdownMenu'],
|
||||
|
||||
data() {
|
||||
return {
|
||||
show: false
|
||||
};
|
||||
},
|
||||
|
||||
created() {
|
||||
const { items } = this.vanDropdownMenu;
|
||||
const index = this.vanDropdownMenu.slots().indexOf(this.$vnode);
|
||||
items.splice(index === -1 ? items.length : index, 0, this);
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
this.vanDropdownMenu.items = this.vanDropdownMenu.items.filter(item => item !== this);
|
||||
},
|
||||
|
||||
computed: {
|
||||
displayTitle() {
|
||||
if (this.title) {
|
||||
@@ -48,7 +39,7 @@ export default sfc({
|
||||
},
|
||||
|
||||
render(h) {
|
||||
const { top, zIndex, activeColor } = this.vanDropdownMenu;
|
||||
const { top, zIndex, activeColor } = this.parent;
|
||||
|
||||
const Options = this.options.map(option => {
|
||||
const active = option.value === this.value;
|
||||
|
Reference in New Issue
Block a user