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

解决方案:

相关文章
相关标签/搜索