vue移動端專案經驗 三

2022-06-28 06:00:12 字數 1768 閱讀 9833

sendcomment()/comment?aid=$`).then(res=>)

}else if(res.data.code==401)).then(()=>

})}).catch(()=>{})}})

}登入頁:

login()/login`,params).then(res=>)

this.$router.replace() //這裡為什麼用replace不用push?因為直接替換路由不會產生新的history記錄。以防止產生新的history記錄導致相關頁面的router.go(-1)出現問題

}else}})

}資料輪詢,使用定時器每過60秒請求一次資料

data()

},created(),

beforedestroy() ,

//若該頁面使用了keepalive快取,則beforedestroy生命週期不可用,改為deactivated生命週期

//deactivated(),

methods:/getdemo?id=$`).then(res=>

})this.settimeget=setinterval(()=>/getdemo?id=$`).then(res=>

})},60000)

},

}

獲取驗證碼
getverifycode()/getverification?t=$`

}

router路由在新視窗開啟頁面
goindex())   //這裡要用resolve方式。 push,go方式無效

window.open(goindex.href,'_blank')

}

銀行卡號每四位空格顯示
銀行卡號正則:

if(/^([1-9])(\d|\d|\d|\d|\d)$/.test(this.cardid)==false)

使用slice或substr或substring分割達到每4位乙個空格效果:

銀行卡號:

$ $ $ $`}}

substr,substring,slice的區別

axios設定請求頭

zfbpay()

}let params=new urlsearchparams()

this.$axios.post(`$/amstc/userrechargeaccountbyalipay`,params,config).then(res=>

}).catch(err=>{})

},

iswechat()  else 

}

判斷是否是ios
ioscheck()else

},

download(url)

全域性部署404(在router/index.js新增)

import notfound from '@/pages/notfound/notfound'   //404

export default new router(

},。。。

},]

beforerouteenter(to, from, next) )

},

input框ios端去除輸入法首字母大寫狀態
goback()else

},

VUE專案測試,移動端

vue專案,進行移動端測試操作步驟 1 執行專案 npm run dev2 電腦建立熱點 3 手機連線熱點,通過本地ip 訪問專案 查詢本地網域名稱 1 windows r 輸入 cmd 2 輸入 ipconfig 3 ipv4 位址 就是ip位址了 4 發現報錯,無法訪問 5 解決 方法一 找到檔...

vue移動端專案手機預覽

1.cmd 輸入ipconfig 獲取本機的ip位址 2.如果是vue cli3搭建的專案 因為沒有config資料夾,這邊需在根目錄新建乙個 vue.config.js檔案基本上所有的一些配製都在這裡,3.在這個檔案裡使用到 所有 webpack dev server 的選項都支援。注意 如果你的...

vue 移動端專案自適應

npm install npm run servevue 移動端專案,需要根據手機螢幕的大小自動適應,避免樣式bug,使用外掛程式專案自動轉化為 rem 布局,未開始或進行中的專案都可以進行配置 通過對 vue 專案進行配置,使得專案在啟動的時候,根據當前裝置的螢幕尺寸把尺寸 px 自動轉化為 re...