Skip to content

Commit

Permalink
feat: 在u-alert组件中添加关闭事件
Browse files Browse the repository at this point in the history
  • Loading branch information
ideal-5 committed Dec 17, 2024
1 parent a93fb41 commit d5081a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/pages/componentsB/alert/alert.nvue
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
type="success"
effect="dark"
closable
@close="close"
showIcon
></up-alert>
</view>
Expand Down Expand Up @@ -129,6 +130,11 @@
description: '',
title: ''
}
},
methods: {
close() {
// console.log('close');
}
}
}
</script>
Expand Down
6 changes: 4 additions & 2 deletions src/uni_modules/uview-plus/components/u-alert/u-alert.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
* @property {String | Number} fontSize 字体大小 (默认 14 )
* @property {Object} customStyle 定义需要用到的外部样式
* @event {Function} click 点击组件时触发
* @event {Function} close 点击关闭按钮时触发
* @example <u-alert :title="title" type = "warning" :closable="closable" :description = "description"></u-alert>
*/
export default {
Expand Down Expand Up @@ -116,7 +117,7 @@
}
}
},
emits: ["click"],
emits: ["click","close"],
methods: {
addUnit,
addStyle,
Expand All @@ -126,7 +127,8 @@
},
// 点击关闭按钮
closeHandler() {
this.show = false
this.show = false
this.$emit('close')
}
}
}
Expand Down

0 comments on commit d5081a9

Please sign in to comment.