目前要開發一個小程序項目,領導要我上手直接就是Taro,語法基本是React的語法(可嘆我是個vue愛好者,以前只是用過RN[0.43]版本,目前都0.59版本了),開發起來比原生的效率要高一點, Taro——一套遵循 React 語法規範的多端統一開發框架
框架名稱 | github-stars | UI框架 | 語法 | 研發團隊 |
---|---|---|---|---|
Taro | 18k | Taro-ui | React語法 | 京東 |
uni-app | 7k | uni-app插件 | Vue語法 | DCloud |
mpvue | 17k | mpvue-weui | Vue語法 | 美團 |
Chameleon | 12k | Chameleon-ui | 小程序語法 | 滴滴 |
從對比stars看Taro優點比較大,從社區羣體上看uni-app在開發這塊仍是頗有潛力的,畢竟一直都在更新中,而且已有現有的開發工具
這是掘進上對比的Taro和uni-app的文章,有對比目前所流行的框架支持度以及生態如何html
canvasToTempFilePath: fail canvas is empty
點擊canvas按鈕我請求一張網絡圖片,一直拋這個異常,查閱文章,網上基本都是小程序生成圖片,不多有關於Tarovue
代碼以下-採坑react
wxDrawImage(){ let that = this; var canvas = Taro.createCanvasContext('shareCanvas',this) canvas.drawImage('https://www.vipbic.com/template/default/public/img/logo.png',0,0,this.state.canvasWidth,this.state.canvasWidth * 1.5) canvas.setTextAlign('center') canvas.setFillStyle('#ffffff') canvas.setFontSize(12) canvas.fillText("生成的文字", this.state.canvasWidth * 0.5, this.state.canvasWidth * 1.26) canvas.stroke(); canvas.draw(true,()=>{ Taro.canvasToTempFilePath({ canvasId: 'shareCanvas', success: function(res) { console.log(res) Taro.saveImageToPhotosAlbum({ filePath: res.tempFilePath, success: function(res) { console.log(res) }, fail: function(err) { console.log(err) } },that) } },that) }) }
如需正確使用,需將Taro.createCanvasContext('shareCanvas',this)
替換Taro.createCanvasContext('shareCanvas',this.$scope)
,小編我也是Google,百度搜了很多文章才知道,也許是我對react理解不夠深刻吧git