tencent.jquery.pix.component 1.0.87 → 1.0.88-beta1

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/change.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # 更新日志
2
2
 
3
+ ### 1.0.88-beta1
4
+
5
+ - getFontSize逻辑优化,获取根元素字体大小
6
+ - 列表组件中优化 itemHeight 的计算方式,改为使用remToPx函数
7
+
8
+
3
9
  ### 1.0.87
4
10
 
5
11
  - waterfallv2 添加下拉刷新功能及相关回调
@@ -1,4 +1,5 @@
1
1
  import { getEnv } from "../config";
2
+ import { remToPx } from "../utils/utils";
2
3
 
3
4
  let $ = null;
4
5
 
@@ -39,9 +40,7 @@ List.prototype.init = function () {
39
40
  if (options.itemHeight.constructor === String) {
40
41
  // 如果是rem单位,则需要计算
41
42
  if (options.itemHeight.indexOf('rem') > -1) {
42
- let fonSize = parseFloat($(document.body).css("font-size").replace('px', ''));
43
- let num = parseFloat(options.itemHeight.replace('rem', ''));
44
- options.itemHeight = fonSize * num;
43
+ options.itemHeight = remToPx(options.itemHeight); // fontSize * num;
45
44
  } else {
46
45
  options.itemHeight = parseFloat(options.itemHeight);
47
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tencent.jquery.pix.component",
3
- "version": "1.0.87",
3
+ "version": "1.0.88-beta1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "files": [
package/utils/utils.js CHANGED
@@ -4,9 +4,18 @@ let fontSize = -1;
4
4
 
5
5
  // 获取字体大小
6
6
  export const getFontSize = () => {
7
+ let htmlFontSize = parseFloat(document.documentElement.style.fontSize.replace('px', ''));
8
+ if (htmlFontSize) {
9
+ return htmlFontSize;
10
+ }
11
+ const baseFontSize = 16; // 默认根元素字体大小
7
12
  if (fontSize === -1) {
8
13
  fontSize = parseFloat($(document.body).css("font-size").replace('px', ''));
9
14
  }
15
+
16
+ if(!fontSize) {
17
+ fontSize = baseFontSize; // 默认字体大小
18
+ }
10
19
  return fontSize;
11
20
  }
12
21