Skip to content

Commit ae8e15e

Browse files
authored
feat(input): 支持readonly下的点击事件 (#76)
1 parent 579d0c3 commit ae8e15e

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

packages/tdesign/input/_example/status/index.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
label="标签文字"
1515
value="不可编辑文字"
1616
disabled
17+
@click="onClick"
1718
/>
1819

1920
<t-input
2021
label="标签文字"
2122
value="只读模式"
2223
readonly
24+
@click="onClick"
2325
/>
2426
</view>
2527
</template>
@@ -34,7 +36,11 @@ export default {
3436
return {};
3537
},
3638
created() {},
37-
methods: {},
39+
methods: {
40+
onClick() {
41+
console.log('click input');
42+
},
43+
},
3844
};
3945
</script>
4046
<style>

packages/tdesign/input/input.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<template>
22
<view
33
:style="_._style([customStyle])"
4-
:class="_.cls(classPrefix, [['border', !borderless]]) + ' ' + classPrefix + '--layout-' + layout + ' ' + tClass"
4+
:class="_.cls(classPrefix, [['border', !borderless], ['readonly', readonly], ['disabled', disabled]])
5+
+ ' ' + classPrefix + '--layout-' + layout + ' ' + tClass"
56
aria-describedby
67
>
78
<view :class="classPrefix + '__wrap--prefix'">
@@ -372,5 +373,16 @@ export default uniComponent({
372373
</script>
373374
<style scoped>
374375
@import './input.css';
375-
376+
/* #ifdef H5 */
377+
.t-input--disabled {
378+
:deep(input) {
379+
pointer-events: none;
380+
}
381+
}
382+
.t-input--readonly {
383+
:deep(input) {
384+
pointer-events: none;
385+
}
386+
}
387+
/* #endif */
376388
</style>

0 commit comments

Comments
 (0)