weex目前遇到的bug總結

研究了一週weex,對遇到的坑和bug作一個總結,能解決的出個解決方案,讓後來的路人少掉坑吧


在<text>元素中,若是設置了字體爲iconfont,文本經過{{}}方式綁定的話,x字符會顯示爲一個相似打印機圖標

參考hayvaneWeex關於字體圖標的bug的回答ios

在template中 text寫死 時,weex-template-compiler在編譯階段使用了he進行decode,而在template中Mustache進行數據綁定fontName(fontName:"&#xe685;")時不會進行decode.正則表達式

解決方案:

方案一

var he = require('he');
 getFontName: function() {
   return he.decode(this.fontName)
 }
方案點評:
  1. 引入了he致使打包體積過大
  2. 須要手動處理很是麻煩
  3. 帶官方解決

方案二:

經過正則表達式將iconfont的字符取出替換,用String.fromCharCode()方法處理segmentfault

decode(text) {
        // 正則匹配 圖標和文字混排 eg: 我去上學校&#xe600;,每天不&#xe600;遲到
        let regExp = /&#x[a-z]\d{3,4};?/;
        if (regExp.test(text)) {
            return text.replace(new RegExp(regExp, 'g'), function (iconText) {
                let replace = iconText.replace(/&#x/, '0x').replace(/;$/, '');
                return String.fromCharCode(replace);
            });
        } else {
            return text;
        }
    }

<refresh>的onpullingdown方法在iOS下拉後會一直調用

同問 weex-playground refresh實例在ios中下拉後,會一直不間斷的觸發onpullingdown方法weex

解決方案:

相關文章
相關標籤/搜索