Skip to content

Commit ef574cf

Browse files
author
xuqingkai
committed
fix: 🐛 修复升级vue到3.4.2.之后defineEmits位置不规范导致访问'emit'报错的问题
Closes: #226
1 parent f4b1e6d commit ef574cf

File tree

55 files changed

+164
-208
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+164
-208
lines changed

src/components/wd-privacy-popup/wd-privacy-popup.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,13 @@ interface Props {
4848
protocol?: string // 协议名称
4949
}
5050
51-
const props = withDefaults(defineProps<Props>(), {
51+
withDefaults(defineProps<Props>(), {
5252
title: '用户隐私保护提示',
5353
desc: '感谢您使用本应用,您使用本应用的服务之前请仔细阅读并同意',
5454
subDesc: '。当您点击同意并开始时用产品服务时,即表示你已理解并同息该条款内容,该条款将对您产生法律约束力。如您拒绝,将无法使用相应服务。',
5555
protocol: '《用户隐私保护指引》'
5656
})
57+
const emit = defineEmits(['agree', 'disagree'])
5758
5859
const showPopup = ref<boolean>(false) // 是否展示popup
5960
@@ -64,8 +65,6 @@ const privacyHandler = (resolve: any) => {
6465
privacyResolves.value.add(resolve)
6566
}
6667
67-
const emit = defineEmits(['agree', 'disagree'])
68-
6968
onBeforeMount(() => {
7069
// 注册监听
7170
if ((wx as any).onNeedPrivacyAuthorization) {

src/uni_modules/wot-design-uni/components/wd-action-sheet/wd-action-sheet.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ import { actionSheetProps, type Panel } from './types'
7676
import { isArray } from '../common/util'
7777
7878
const props = defineProps(actionSheetProps)
79+
const emit = defineEmits(['select', 'click-modal', 'cancel', 'closed', 'close', 'open', 'opened', 'update:modelValue'])
80+
7981
const formatPanels = ref<Array<Panel> | Array<Panel[]>>([])
8082
8183
const showPopup = ref<boolean>(false)
@@ -90,8 +92,6 @@ watch(
9092
{ deep: true, immediate: true }
9193
)
9294
93-
const emit = defineEmits(['select', 'click-modal', 'cancel', 'closed', 'close', 'open', 'opened', 'update:modelValue'])
94-
9595
function isPanelArray() {
9696
return props.panels.length && !isArray(props.panels[0])
9797
}

src/uni_modules/wot-design-uni/components/wd-button/wd-button.vue

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,26 @@ const loadingIcon = (color = '#4D80F0', reverse = true) => {
7171
}"/><path d="M4.599 21c0 9.044 7.332 16.376 16.376 16.376 9.045 0 16.376-7.332 16.376-16.376" stroke="url(#a)" stroke-width="3.5" stroke-linecap="round"/></g></svg>`
7272
}
7373
const props = defineProps(buttonProps)
74+
const emit = defineEmits([
75+
'click',
76+
'getuserinfo',
77+
'contact',
78+
'getphonenumber',
79+
'error',
80+
'launchapp',
81+
'opensetting',
82+
'chooseavatar',
83+
'agreeprivacyauthorization'
84+
])
7485
7586
const hoverStartTime = ref<number>(20)
7687
const hoverStayTime = ref<number>(70)
7788
const loadingIconSvg = ref<string>('')
7889
90+
const loadingStyle = computed(() => {
91+
return `background-image: url(${loadingIconSvg.value});`
92+
})
93+
7994
watch(
8095
() => props.loading,
8196
() => {
@@ -84,22 +99,6 @@ watch(
8499
{ deep: true, immediate: true }
85100
)
86101
87-
const loadingStyle = computed(() => {
88-
return `background-image: url(${loadingIconSvg.value});`
89-
})
90-
91-
const emit = defineEmits([
92-
'click',
93-
'getuserinfo',
94-
'contact',
95-
'getphonenumber',
96-
'error',
97-
'launchapp',
98-
'opensetting',
99-
'chooseavatar',
100-
'agreeprivacyauthorization'
101-
])
102-
103102
function handleClick(event: any) {
104103
if (!props.disabled && !props.loading) {
105104
emit('click', event.detail)

src/uni_modules/wot-design-uni/components/wd-calendar-view/month/month.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,14 @@ import type { CalendarDayItem, CalendarDayType, CalendarType } from '../types'
5656
import { monthProps } from './types'
5757
5858
const props = defineProps(monthProps)
59+
const emit = defineEmits(['change'])
5960
6061
const { translate } = useTranslate('calendar-view')
6162
6263
const days = ref<Array<CalendarDayItem>>([])
6364
65+
const toast = useToast('wd-month')
66+
6467
const itemClass = computed(() => {
6568
return (monthType: CalendarDayType, value: number | (number | null)[], type: CalendarType) => {
6669
return getItemClass(monthType, value, type)
@@ -89,10 +92,6 @@ watch(
8992
}
9093
)
9194
92-
const toast = useToast('wd-month')
93-
94-
const emit = defineEmits(['change'])
95-
9695
function setDays() {
9796
const dayList: Array<CalendarDayItem> = []
9897
const date = new Date(props.date)

src/uni_modules/wot-design-uni/components/wd-calendar-view/monthPanel/month-panel.vue

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ import { useTranslate } from '../../composables/useTranslate'
6969
import type { CalendarItem } from '../types'
7070
7171
const props = defineProps(monthPanelProps)
72+
const emit = defineEmits(['change', 'pickstart', 'pickend'])
73+
7274
const { translate } = useTranslate('calendar-view')
7375
7476
const scrollTop = ref<number>(0) // 滚动位置
@@ -78,6 +80,12 @@ const timeValue = ref<number[]>([]) // 当前选中的时分秒
7880
const timeType = ref<MonthPanelTimeType>('') // 当前时间类型,是开始还是结束
7981
const innerValue = ref<string | number | (number | null)[]>('') // 内部保存一个值,用于判断新老值,避免监听器触发
8082
83+
const handleChange = debounce((value) => {
84+
emit('change', {
85+
value
86+
})
87+
}, 50)
88+
8189
// 时间picker的列数据
8290
const timeData = computed<Array<CalendarItem[]>>(() => {
8391
let timeColumns: Array<CalendarItem[]> = []
@@ -172,14 +180,6 @@ onMounted(() => {
172180
scrollIntoView()
173181
})
174182
175-
const emit = defineEmits(['change', 'pickstart', 'pickend'])
176-
177-
const handleChange = debounce((value) => {
178-
emit('change', {
179-
value
180-
})
181-
}, 50)
182-
183183
/**
184184
* 使当前日期或者选中日期滚动到可视区域
185185
*/

src/uni_modules/wot-design-uni/components/wd-calendar-view/wd-calendar-view.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ import MonthPanel from './monthPanel/month-panel.vue'
5858
import { calendarViewProps, type CalendarViewExpose } from './types'
5959
6060
const props = defineProps(calendarViewProps)
61-
61+
const emit = defineEmits(['change', 'update:modelValue', 'pickstart', 'pickend'])
6262
const formatDefauleTime = ref<number[][]>([])
6363
6464
const yearPanelRef = ref()
@@ -75,8 +75,6 @@ watch(
7575
}
7676
)
7777
78-
const emit = defineEmits(['change', 'update:modelValue', 'pickstart', 'pickend'])
79-
8078
/**
8179
* 使当前日期或者选中日期滚动到可视区域
8280
*/

src/uni_modules/wot-design-uni/components/wd-calendar-view/year/year.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ import { yearProps } from './types'
3838
import type { CalendarDayItem, CalendarDayType, CalendarType } from '../types'
3939
4040
const props = defineProps(yearProps)
41+
const emit = defineEmits(['change'])
42+
4143
const toast = useToast('wd-year')
4244
const { translate } = useTranslate('calendar-view')
4345
@@ -55,8 +57,6 @@ const yearTitle = computed(() => {
5557
}
5658
})
5759
58-
const emit = defineEmits(['change'])
59-
6060
watch(
6161
[() => props.type, () => props.date, () => props.value, () => props.minDate, () => props.maxDate, () => props.formatter],
6262
() => {

src/uni_modules/wot-design-uni/components/wd-calendar-view/yearPanel/year-panel.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import Year from '../year/year.vue'
3838
import { yearPanelProps, type YearInfo, type YearPanelExpose } from './types'
3939
4040
const props = defineProps(yearPanelProps)
41+
const emit = defineEmits(['change'])
4142
4243
const scrollTop = ref<number>(0) // 滚动位置
4344
const scrollIndex = ref<number>(0) // 当前显示的年份索引
@@ -63,8 +64,6 @@ const title = computed(() => {
6364
return formatYearTitle(years.value[scrollIndex.value].date)
6465
})
6566
66-
const emit = defineEmits(['change'])
67-
6867
onMounted(() => {
6968
scrollIntoView()
7069
})

src/uni_modules/wot-design-uni/components/wd-calendar/wd-calendar.vue

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ const formatRange = (value: number, rangeType: 'start' | 'end', type: CalendarTy
200200
}
201201
202202
const props = defineProps(calendarProps)
203+
const emit = defineEmits(['cancel', 'change', 'update:modelValue', 'confirm'])
203204
204205
const pickerShow = ref<boolean>(false)
205206
const calendarValue = ref<null | number | number[]>(null)
@@ -211,6 +212,9 @@ const lastTab = ref<number>(0)
211212
const currentType = ref<CalendarType>('date')
212213
const lastCurrentType = ref<CalendarType>()
213214
const inited = ref<boolean>(false)
215+
const cell = useCell()
216+
const calendarView = ref()
217+
const calendarTabs = ref()
214218
215219
const rangeLabel = computed(() => {
216220
const [start, end] = deepClone(isArray(calendarValue.value) ? calendarValue.value : [])
@@ -227,11 +231,6 @@ const showValue = computed(() => {
227231
}
228232
})
229233
230-
const cell = useCell()
231-
232-
const calendarView = ref()
233-
const calendarTabs = ref()
234-
235234
watch(
236235
() => props.modelValue,
237236
(val, oldVal) => {
@@ -305,8 +304,6 @@ const range = computed(() => {
305304
}
306305
})
307306
308-
const emit = defineEmits(['cancel', 'change', 'update:modelValue', 'confirm'])
309-
310307
function scrollIntoView() {
311308
calendarView.value && calendarView.value && calendarView.value.$.exposed.scrollIntoView()
312309
}

src/uni_modules/wot-design-uni/components/wd-cell/wd-cell.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ import { FORM_KEY } from '../wd-form/types'
6565
import { cellProps } from './types'
6666
6767
const props = defineProps(cellProps)
68+
const emit = defineEmits(['click'])
6869
6970
const cell = useCell()
7071
@@ -96,8 +97,6 @@ const isRequired = computed(() => {
9697
return props.required || props.rules.some((rule) => rule.required) || formRequired
9798
})
9899
99-
const emit = defineEmits(['click'])
100-
101100
/**
102101
* @description 点击cell的handle
103102
*/

0 commit comments

Comments
 (0)