From c48c46335da9cc3ec25fd8158ff6c18a7057d1ef Mon Sep 17 00:00:00 2001
From: JM <743192023@qq.com>
Date: Wed, 25 Dec 2019 14:19:25 +0800
Subject: [PATCH] Perfect: [issue35] & [issue36]
---
src/components/scrollRankingBoard/src/main.vue | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/components/scrollRankingBoard/src/main.vue b/src/components/scrollRankingBoard/src/main.vue
index 320a593..f349096 100644
--- a/src/components/scrollRankingBoard/src/main.vue
+++ b/src/components/scrollRankingBoard/src/main.vue
@@ -8,7 +8,7 @@
>
No.{{ item.ranking }}
-
{{ item.name }}
+
{{ item.value + mergedConfig.unit }}
@@ -76,7 +76,13 @@ export default {
* @default unit = ''
* @example unit = 'ton'
*/
- unit: ''
+ unit: '',
+ /**
+ * @description Auto sort by value
+ * @type {Boolean}
+ * @default sort = true
+ */
+ sort: true
},
mergedConfig: null,
@@ -137,9 +143,9 @@ export default {
this.mergedConfig = deepMerge(deepClone(defaultConfig, true), config || {})
},
calcRowsData () {
- let { data, rowNum } = this.mergedConfig
+ let { data, rowNum, sort } = this.mergedConfig
- data.sort(({ value: a }, { value: b }) => {
+ sort && data.sort(({ value: a }, { value: b }) => {
if (a > b) return -1
if (a < b) return 1
if (a === b) return 0