Skip to content

Commit

Permalink
fix: uni-app-x版本popup
Browse files Browse the repository at this point in the history
  • Loading branch information
jry committed Sep 12, 2024
1 parent 7d50a20 commit 4e77f32
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
:hover-class="!disabled && !loading ? 'up-button--active' : ''"
class="up-button up-reset-button"
:style="[baseColor, nvueTextStyle, addStyle(customStyle)]"
@tap="clickHandler"
@click="clickHandler"
:class="bemClass"
>
<template v-if="loading">
Expand Down Expand Up @@ -236,11 +236,14 @@ export default {
clickHandler(): void {
// 非禁止并且非加载中,才能点击
if (!this.disabled && !this.loading) {
console.log('点击');
// 进行节流控制,每throttle毫秒内,只在开始处执行
throttle(() => {
this.$emit("click");
}, this.throttleTime);
}
} else {
console.log('禁止点击');
}
},
// 下面为对接uniapp官方按钮开放能力事件回调的对接
getphonenumber(res: UTSJSONObject): void {
Expand Down
2 changes: 1 addition & 1 deletion src/uni_modules/uview-plus/components/up-icon/props.uts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const propsIcon = defineMixin({
},
// 字体大小,单位px
size: {
type: [String],
type: [String, Number],
default: crtProp['size']
},
// 是否显示粗体
Expand Down
8 changes: 4 additions & 4 deletions src/uni_modules/uview-plus/components/up-icon/up-icon.uvue
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@
},
iconStyle(): any {
let style = {
fontSize: addUnit(this.size),
lineHeight: addUnit(this.size),
fontSize: addUnit(this.size.toString()),
lineHeight: addUnit(this.size.toString()),
fontWeight: this.bold ? 'bold' : 'normal',
// 某些特殊情况需要设置一个到顶部的距离,才能更好的垂直居中
top: addUnit(this.top)
Expand All @@ -120,8 +120,8 @@
imgStyle(): any {
let style = {}
// 如果设置width和height属性,则优先使用,否则使用size属性
style['width'] = this.width != '' ? addUnit(this.width) : addUnit(this.size)
style['height'] = this.height != '' ? addUnit(this.height) : addUnit(this.size)
style['width'] = this.width != '' ? addUnit(this.width) : addUnit(this.size.toString())
style['height'] = this.height != '' ? addUnit(this.height) : addUnit(this.size.toString())
return style
},
// 通过图标名,查找对应的图标
Expand Down
7 changes: 5 additions & 2 deletions src/uni_modules/uview-plus/components/up-popup/up-popup.uvue
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,12 @@
mixins: [mpMixin, mixin, propsPopup],
data() {
return {
overlayDuration: parseInt(this.duration.toString()) + 50
overlayDuration: 0
}
},
created() {
this.overlayDuration = parseInt(this.duration.toString()) + 50
},
watch: {
show(newValue, oldValue) {
if (newValue === true) {
Expand All @@ -95,7 +98,7 @@
computed: {
transitionStyle():any {
const style = {
zIndex: parseInt(this.zIndex),
zIndex: parseInt(this.zIndex.toString()),
position: 'fixed',
display: 'flex',
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const propsTransition = defineMixin({
},
// 动画的执行时间,单位ms
duration: {
type: [Number],
type: [Number, String],
default: crtProp['duration']
},
// 使用的动画过渡函数
Expand Down
10 changes: 5 additions & 5 deletions uni-app-x/pages/componentsA/popup/popup.uvue
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@
marginTop: ['left', 'right'].includes(getMode(popupData)) ? '480rpx' : '0',
}"
>
<up-button
<up-tag
type="success"
text="点我关闭"
customStyle="width: 200rpx"
@click="show = !show"
></up-button>
@click="close"
></up-tag>
</view>
</up-popup>
</view>
Expand Down Expand Up @@ -162,7 +162,7 @@
openPopup(popupData?: UTSJSONObject): void {
this.popupData = popupData as UTSJSONObject
// sleep().then(() => {
// this.show = !this.show
this.show = !this.show
// })
},
navigateBack(): void {
Expand All @@ -180,7 +180,7 @@
},
close(): void {
this.show = false
// console.log('close');
console.log('close');
}
}
}
Expand Down

0 comments on commit 4e77f32

Please sign in to comment.