Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tabs): 修复Tabs在ios低版本不渲染(#247) #514

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/uni_modules/wot-design-uni/components/wd-tabs/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { type ExtractPropTypes, type InjectionKey } from 'vue'
import { baseProps, makeBooleanProp, makeNumberProp, makeNumericProp, makeStringProp, numericProp } from '../common/props'
import type { TabProps } from '../wd-tab/types'

export type TabsProvide = {
state: {
Expand Down Expand Up @@ -62,3 +63,5 @@ export const tabsProps = {
}

export type TabsProps = ExtractPropTypes<typeof tabsProps>

export type TTabProps = Pick<TabProps, 'name' | 'title' | 'disabled'>
13 changes: 9 additions & 4 deletions src/uni_modules/wot-design-uni/components/wd-tabs/wd-tabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export default {
import { computed, getCurrentInstance, onMounted, ref, watch, nextTick, reactive, type CSSProperties } from 'vue'
import { addUnit, checkNumRange, debounce, getRect, isDef, isNumber, isString, objToStyle } from '../common/util'
import { useTouch } from '../composables/useTouch'
import { TABS_KEY, tabsProps } from './types'
import { TABS_KEY, tabsProps, TTabProps } from './types'
import { useChildren } from '../composables/useChildren'
import { useTranslate } from '../composables/useTranslate'

Expand Down Expand Up @@ -174,10 +174,15 @@ const { proxy } = getCurrentInstance() as any
const touch = useTouch()

// tabs数据
const items = computed(() => {
return children.map((child, index) => {
return { disabled: child.disabled, title: child.title, name: isDef(child.name) ? child.name : index }
const items = ref<TTabProps[]>([])
// 解决ios低版本tabs不渲染
watch(children, newChildren => {
items.value = newChildren.map((child, index) => {
return { disabled: child.disabled, title: child.title, name: isDef(child.name)? child.name : index }
})
}, {
deep: true,
flush: 'post'
})

const bodyStyle = computed(() => {
Expand Down