RN weex hippy tarojavascript
類型 | React Native | Weex | |
思想 | learn once, write anywhere | write once, run anywhere | |
擴展 | 不一樣平臺可自由擴展 | 爲了保證各平臺的一致性,一次擴展得在各個平臺都實現 | |
組件豐富程度 | 除了自帶的,還有js.coach上社區貢獻的,仍是比較豐富的 | 基本只有自帶的10餘種 | |
調式 | 有專門的調試工具,chrome調試,較爲完善 | 暫時log調試 | |
性能 | 較好 | 較弱 | |
上手難度 | 稍高 | 容易 | |
核心理念 | React | Vue | |
框架程度 | 較重 | 較輕 | |
特色 | 適合開發總體App | 適合單頁面 | |
社區 | 豐富,Facebook維護 | 略殘念,目前託管apache | |
支持 | Android、IOS | Android、IOS、Web | |
適應性 | 原生開學習成本低 | Web開發學習成本低 | |
JS引擎 | JSCore | V8 |
如下針對於iOS,編譯和運行時報錯處理:html
錯誤:前端
./src/index.vue Module build failed: Error: Vue packages version mismatch: - vue@2.5.21 (/Users/admin/.wx/modules/node_modules/_vue@2.5.21@vue/dist/vue.runtime.common.js) - vue-template-compiler@2.6.10 (/Users/admin/.wx/modules/node_modules/_vue-template-compiler@2.6.10@vue-template-compiler/package.json)
解決:vue
$ weex repair @weex-cli/core@latest $ weex update @weex-cli/doctor $ weex doctor
運行 weex debug 命令啓動調試控制檯,必須使用chrome 瀏覽器調試java
運行npm run dev,出現eslint報錯。
解決:在config.js文件中,useEslint: false,node
https://blog.csdn.net/u012182...webpack
Weex默認是單頁面效果,首先,Weex真正運行的是,經過entry.js做爲入口文件文件,經過webpack,將.vue文件打包成index.js進行使用。多頁面的重點,就是將獨立頁面的.vue文件,生成多個js文件。
weexConfig的入口和出口配置(iOS/Android):ios
參考entry.js文件,建立一個listeEntry.js,做爲liste.vue的入口,用於webpack生成list.js頁面。web
const { router } = require('./router') const List = require('@/list.vue') /* eslint-disable no-new */ new Vue(Vue.util.extend({el: '#root', router}, List)) router.push('/')
修改webpack.common.conf.js文件chrome
const weexEntry = {
'index': helper.root('entry.js'), 'list': helper.root('listEntry.js'), }
webConfig的入口和出口配置(web)
1.在configs/webpack.common.conf.js下修改getEntryFile()函數
const getEntryFile = () => { const entryFile = path.join(vueWebTemp, config.entryFilePath) const routerFile = path.join(vueWebTemp, config.routerFilePath) fs.outputFileSync(entryFile, getEntryFileContent(helper.root(config.entryFilePath), routerFile)); fs.outputFileSync(routerFile, getRouterFileContent(helper.root(config.routerFilePath))); const listFilePath = 'listEntry.js' const listFile = path.join(vueWebTemp, listFilePath) fs.outputFileSync(listFile, getEntryFileContent(helper.root(listFilePath), routerFile)); return { index: entryFile, list: listFile, } }
2.在.temp文件下建立listEntry.js的webConfig入口文件。
const { router } = require('./router') const List = require('@/list.vue') /* eslint-disable no-new */ new Vue(Vue.util.extend({el: '#root', router}, List)) router.push('/')
Weex僅有Flexbox佈局,text沒法嵌套,難以實現長文當中樣式的混合。
沒有Cookies.只能用storage來完成對應信息的存儲。
擴展:https://weex.apache.org/zh/gu...
const vvModule = weex.requireModule('VVWeexModule'); vvModule.setGlobalCallback( res => { this.info = res; console.log(JSON.stringify(res)); }); vvModule.logInNative('aaa');
Weex Toolkit:https://weex.apache.org/zh/to...