Skip to content

Commit cd74f82

Browse files
author
Dewyzee
committed
update component cell
1 parent e6cc4a2 commit cd74f82

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

src/components/cell/cell.vue

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div>
3-
<div @click="handleTap" class="i-class i-cell">
3+
<div @click="handleTap" class="i-class i-cell" v-bind:class="{'i-cell-last': isLastCell, 'i-cell-access': isLink}">
44
<div class="i-cell-icon">
55
<slot name="icon"></slot>
66
</div>
@@ -11,7 +11,7 @@
1111
</div>
1212
<div @click.capture="navigateTo" class="i-cell-ft">
1313
<div v-if="value">{{ value }}</div>
14-
<div v-else="">
14+
<div v-else>
1515
<slot name="footer"></slot>
1616
</div>
1717
</div>
@@ -51,7 +51,33 @@ export default {
5151
url: {
5252
type: String,
5353
value: ''
54+
},
55+
isLastCell: {
56+
type: Boolean,
57+
value: false
58+
}
59+
},
60+
methods: {
61+
navigateTo(evt) {
62+
const navigateTypes = ['navigateTo', 'redirectTo', 'switchTab', 'reLaunch']
63+
const url = this.url
64+
const type = typeof this.isLink
65+
this.$emit('click', evt)
66+
if (type !== 'boolean' || type !== 'string') {
67+
console.warn('isLink 属性必须是一个字符串或者布尔值', this.isLink)
68+
return
69+
}
70+
if (!navigateTypes.includes(this.linkType)) {
71+
console.warn('linkType 属性可选值为 navigateTo,redirectTo,switchTab,reLaunch', this.linkType)
72+
return
73+
}
74+
mpvue[this.linkType].call(mpvue, { url })
75+
},
76+
handleTap() {
77+
if (!this.onlyTapFooter) {
78+
this.navigateTo()
79+
}
5480
}
55-
}
81+
},
5682
}
5783
</script>

0 commit comments

Comments
 (0)