Skip to content

Commit 1a10521

Browse files
authored
fix(dropdown-mobile): 修复移动端组件dropdownMenu无法正常渲染的问题,顺带修复pc端dropDown组件的警告 (#35)
1 parent facc16c commit 1a10521

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/dropdown-item/vue.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,13 @@ const initApi = ({ api, state, emit, props, parent, dispatch, vm }) => {
9393
})
9494
}
9595

96-
export const renderless = (props, { computed, reactive, watch, inject }, { parent, emit, vm, dispatch }) => {
96+
export const renderless = (props, { computed, reactive, watch, inject }, { parent, emit, vm, dispatch, mode }) => {
9797
const api = {}
9898
const dropdownMenu = inject('dropdownMenu', null)
9999

100+
if (mode === 'mobile') {
101+
dropdownMenu.state.children = [...dropdownMenu.state.children, vm]
102+
}
100103
parent = parent.$parent
101104

102105
const state = initState({ reactive, computed, api, props, parent, dropdownMenu })

src/dropdown-menu/vue.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ export const api = ['state', 'toggleItem', 'updateOffset', 'clickOutside', 'doDe
1616

1717
export const renderless = (props, hooks, instance) => {
1818
const api = {}
19-
const { reactive } = hooks
20-
const { refs, nextTick, mode } = instance
19+
const { reactive, provide } = hooks
20+
const { refs, nextTick, mode, vm } = instance
2121
const state = reactive({
2222
offset: 0,
2323
scroller: null,
@@ -27,6 +27,7 @@ export const renderless = (props, hooks, instance) => {
2727
})
2828

2929
if (mode === 'mobile') {
30+
provide('dropdownMenu', vm)
3031
nextTick(() => {
3132
state.scroller = getScroller(refs.menu)
3233
})

0 commit comments

Comments
 (0)