認識weexplushtml
weexplus是基於weex官方的二次開發版本,weex和react native同樣同屬第2代跨平臺技術,解決了第一代性能低下,體驗很差的問題,同時保留了第一代 多平臺一套代碼,基於web技術棧,支持動態發版 等全部優勢。--weexplus腳手架做者前端
開發vue
$ npm install weex-toolkit -g $ npm install weexplus -g $ git clone XXX //下載項目到本地 $ cd XXX // 進入項目根目錄 $ npm install $ npm run dev $ npm run weexplus
那些坑node
$ npm install -g cnpm --registry=https://registry.npm.taobao.org
//在列表頁註冊頁面 var notify=weex.requireModule('notify'); notify.regist('twoPlusListTab',(p)=>{ this.status=p.index; }) navigator.setPageId('twoPlusList');//惟一,最好根據當前頁面的文件名來命名 //最後的操做頁面返回到首頁 var notify=weex.requireModule('notify'); notify.send('twoPlusListTab', {index:0});//傳參 nav.backTo('twoPlusList');//返回到列表
//須要返回刷新 //在列表頁註冊頁面 var notify=weex.requireModule('notify'); notify.regist('twoPlusListTab',(p)=>{ this.status=p.index; }) //須要在全局事件監聽裏設置setPageId globalEvent.addEventListener("onPageInit", () => { navigator.setPageId('twoPlusList');//惟一 }) //在須要刷新的頁面 var that = this; var notify=weex.requireModule('notify'); notify.regist('threeUnlinkList',(p)=>{ that.refresh();//頁面須要有刷新方法 }) //最後的操做頁面返回到列表頁 twoPlusList,須要寫到數據請求的回調函數裏 net.post("sinochem/tripartiteContract/add", query, res => { modal.toast({ message: "保存成功!" }); var notify=weex.requireModule('notify'); notify.send('twoPlusListTab', {index:0});//傳參到列表頁 notify.send('threeUnlinkList', {})//跟須要刷新的頁面通訊 navigator.backTo('twoPlusList');//返回到列表頁 });
經常使用代碼塊react
var modal = weex.requireModule('modal'); modal.alert({ message: 'This is a alert', duration: 0.3 }, function (value) { console.log('alert callback', value) })
//不須要回調函數簡寫 modal.alert({message:'This is a alert');
//確認框 modal.confirm({ message: 'Do you confirm ?', duration: 0.3 }, function (value) { console.log('confirm callback', value) })
// 有回調函數的確認框 modal.confirm( { message:"this is message", okTitle: "確認", cancelTitle: "取消" }, function(obj) { if (obj == "確認") { modal.alert({message:'確認'}); } else { modal.alert({message:'取消'}); } } );
//只能輸數字 不能輸負數(金額、面積) if(!(/^[-]?[0-9]*\.?[0-9]+(eE?[0-9]+)?$/).test(this.area)||this.area<=0){ modal.toast({message:'請輸入正確的合同面積'}) return false; }
// 校驗身份證號 if(!(/(^\d{15}$)|(^\d{17}([0-9]|X)$)/).test(p.identityCode)){ modal.toast({ message: "請輸入正確的身份證號" }); return; }
文檔git
其餘github