feat(Picker): add readonly prop (#7105)

This commit is contained in:
neverland
2020-09-05 06:50:59 +08:00
committed by GitHub
parent f6e3aaebec
commit 3cd200f7c2
6 changed files with 33 additions and 1 deletions
+14 -1
View File
@@ -31,6 +31,7 @@ export default createComponent({
props: {
valueKey: String,
readonly: Boolean,
allowHtml: Boolean,
className: String,
itemHeight: Number,
@@ -99,6 +100,10 @@ export default createComponent({
},
onTouchStart(event) {
if (this.readonly) {
return;
}
this.touchStart(event);
if (this.moving) {
@@ -116,6 +121,10 @@ export default createComponent({
},
onTouchMove(event) {
if (this.readonly) {
return;
}
this.touchMove(event);
if (this.direction === 'vertical') {
@@ -137,6 +146,10 @@ export default createComponent({
},
onTouchEnd() {
if (this.readonly) {
return;
}
const distance = this.offset - this.momentumOffset;
const duration = Date.now() - this.touchStartTime;
const allowMomentum =
@@ -164,7 +177,7 @@ export default createComponent({
},
onClickItem(index) {
if (this.moving) {
if (this.moving || this.readonly) {
return;
}