xianniu-ui 0.9.9 → 0.9.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xianniu-ui",
3
- "version": "0.9.9",
3
+ "version": "0.9.12",
4
4
  "private": false,
5
5
  "main": "lib/xianniu-ui.umd.min.js",
6
6
  "scripts": {
@@ -10,7 +10,7 @@
10
10
  </i><!--
11
11
  --><slot>{{
12
12
  formatValue
13
- | doPrecision(legalPrecision, isRoundUp)
13
+ | doPrecision(legalPrecision, isRoundUp, emptyValue)
14
14
  | doFormat(hasSeparator, separator)
15
15
  }}</slot><!--
16
16
  --><i
@@ -22,7 +22,7 @@
22
22
  </i>
23
23
  </template>
24
24
  <template v-else>
25
- {{ formatValue | doPrecision(4, isRoundUp) | doCapital }}
25
+ {{ formatValue | doPrecision(4, isRoundUp, emptyValue) | doCapital }}
26
26
  </template>
27
27
  </span>
28
28
  </template>
@@ -93,10 +93,19 @@ export default {
93
93
  type: Object,
94
94
  default: () => ({}),
95
95
  },
96
+ emptyValue: {
97
+ type: String,
98
+ default: "--",
99
+ },
96
100
  },
97
101
  filters: {
98
102
  // 处理精度
99
- doPrecision(value, precision, isRoundUp) {
103
+ doPrecision(value, precision, isRoundUp, emptyValue = '--') {
104
+ // 处理空值情况
105
+ if (value == null || isNaN(value)) {
106
+ return emptyValue;
107
+ }
108
+
100
109
  const exponentialForm = Number(`${value}e${precision}`);
101
110
  const rounded = isRoundUp
102
111
  ? Math.round(exponentialForm)