x
字符會顯示爲一個相似打印機圖標參考hayvane在Weex關於字體圖標的bug的回答ios
在template中 text寫死 時,weex-template-compiler在編譯階段使用了he進行decode,而在template中Mustache進行數據綁定fontName(fontName:"")時不會進行decode.正則表達式
var he = require('he'); getFontName: function() { return he.decode(this.fontName) }
he
致使打包體積過大經過正則表達式將iconfont的字符取出替換,用String.fromCharCode()方法處理segmentfault
decode(text) { // 正則匹配 圖標和文字混排 eg: 我去上學校,每天不遲到 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; } }
onpullingdown
方法在iOS下拉後會一直調用同問 weex-playground refresh實例在ios中下拉後,會一直不間斷的觸發onpullingdown方法weex
無