mini-program-parser
Advanced tools
@@ -13,2 +13,4 @@ Component({ | ||
| }, | ||
| queryTimer: null, | ||
| queryCount: 0, | ||
| ready() { | ||
@@ -19,2 +21,15 @@ const { html, config } = this.data; | ||
| if (adaptive) { | ||
| this.queryTimer = setInterval(() => { | ||
| this.getContainerWidth(); | ||
| }, 100); | ||
| } else { | ||
| this.setData({ | ||
| renderVisible: true, | ||
| }); | ||
| } | ||
| } | ||
| }, | ||
| methods: { | ||
| getContainerWidth() { | ||
| if (this.queryTimer || this.queryCount > 20) { | ||
| // 获取外层容器宽度 | ||
@@ -26,2 +41,3 @@ wx.createSelectorQuery() | ||
| if (res && res.width > 0) { | ||
| this.queryTimer = null; | ||
| this.setData({ | ||
@@ -31,12 +47,10 @@ containerWidth: res.width, | ||
| }); | ||
| } else { | ||
| this.queryCount += 1; | ||
| } | ||
| }) | ||
| .exec(); | ||
| } else { | ||
| this.setData({ | ||
| renderVisible: true, | ||
| }); | ||
| } | ||
| } | ||
| }, | ||
| }, | ||
| }); |
+1
-1
| { | ||
| "name": "mini-program-parser", | ||
| "version": "0.3.2", | ||
| "version": "0.3.3", | ||
| "scripts": { | ||
@@ -5,0 +5,0 @@ "dev": "rollup -c ./rollup.dev.config.js --watch", |
Sorry, the diff of this file is not supported yet
53548
0.71%1009
1.41%