|
@@ -60,29 +60,37 @@ Component({
|
|
|
this.rander(lookItem.content)
|
|
|
});
|
|
|
},
|
|
|
- rander(html) {
|
|
|
- this.setHeight();
|
|
|
- if (editor == null) {
|
|
|
- wx.createSelectorQuery().in(this).select('#editor').context(function (res) {
|
|
|
- editor = res.context;
|
|
|
- this.rander(html)
|
|
|
- }).exec()
|
|
|
- } else {
|
|
|
- editor.setContents({
|
|
|
- html,
|
|
|
- complete: res => {
|
|
|
- console.log("渲染富文本", res)
|
|
|
- }
|
|
|
- })
|
|
|
- };
|
|
|
+ async rander(html) {
|
|
|
+ this.setHeight().then(s => {
|
|
|
+ if (editor == null) {
|
|
|
+ wx.createSelectorQuery().in(this).select('#editor').context(function (res) {
|
|
|
+ editor = res.context;
|
|
|
+ this.rander(html)
|
|
|
+ }).exec()
|
|
|
+ } else {
|
|
|
+ editor.setContents({
|
|
|
+ html,
|
|
|
+ complete: res => {
|
|
|
+ console.log("渲染富文本", res)
|
|
|
+ if (this.data.height == 0) setTimeout(() => {
|
|
|
+ this.rander(html)
|
|
|
+ }, 50)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ };
|
|
|
+ })
|
|
|
+
|
|
|
},
|
|
|
- async setHeight() {
|
|
|
- let boxHeight = await this.queryElement(".box", "height"),
|
|
|
- headHeight = await this.queryElement(".head", "height"),
|
|
|
- bottomHeight = await this.queryElement(".bottom", "height"),
|
|
|
- height = boxHeight - headHeight - bottomHeight - 5;
|
|
|
- this.setData({
|
|
|
- height
|
|
|
+ setHeight() {
|
|
|
+ return new Promise(async (resolve) => {
|
|
|
+ let boxHeight = await this.queryElement(".box", "height"),
|
|
|
+ headHeight = await this.queryElement(".head", "height"),
|
|
|
+ bottomHeight = await this.queryElement(".bottom", "height"),
|
|
|
+ height = boxHeight - headHeight - bottomHeight - 5;
|
|
|
+ this.setData({
|
|
|
+ height
|
|
|
+ })
|
|
|
+ resolve(height)
|
|
|
})
|
|
|
},
|
|
|
queryElement(element, field) {
|