添加 backable 控制返回按钮是否可用

This commit is contained in:
icssoa
2025-10-17 23:24:19 +08:00
parent 6ca04b1d62
commit 7826f5cf8b

View File

@@ -15,7 +15,7 @@
<view v-if="showBack" class="cl-topbar__icon" @tap="back()">
<cl-icon
:pt="{
className: pt.back?.className
className: parseClass([[!backable, 'opacity-50'], pt.back?.className])
}"
:name="backIcon"
:size="pt.back?.size ?? 48"
@@ -82,6 +82,11 @@ const props = defineProps({
type: Boolean,
default: true
},
// 是否可以返回
backable: {
type: Boolean,
default: true
},
// 返回按钮的跳转路径
backPath: {
type: String,
@@ -195,6 +200,7 @@ const topbarStyle = computed(() => {
// 返回按钮点击事件
function back() {
if (props.backable) {
if (props.backPath != "") {
router.to(props.backPath);
} else {
@@ -204,6 +210,7 @@ function back() {
router.back();
}
}
}
}
</script>