公司要实现一套web管理系统和一套员工运维系统,最开始的时候后台使用VUE搭建,由于运维app使用的都是内部人员,因此就使用mui来写了。
后来老大发现两端代码有部分重叠,就准备使用一套代码,而后我就开始了对vue项目的mui改造,主要是为了调用mui中提供的原生APIhtml
vue搭建环境、HBuilder编辑器。(我不喜欢用Hbuilder写代码,在使用VScode)vue
使用的是vue-cli脚手架。 ios
assetsPublicPath: './' // 以前是 '/' 改成 './' 使build以后的项目能在本地运行
productionSourceMap: false // 删除打包以后生产的map文件,减小打包以后的大小
复制代码
mounted(){
console.log(mui)
},
复制代码
toast(){
mui.toast('mui.toast')
}
复制代码
(写完发现很墨迹,会的直接略过吧)git
mounted(){
mui.plusReady(()=>{
console.log('plus加载完成')
console.log(JSON.stringify(plus))
})
},
methods:{
goBack(){
this.$router.go(-1)
},
Photograph(){
getImage(res=>{
this.imgSrc = res
})
}
}
复制代码
//判断是不是ios环境
function isIos() {
if (/iPhone|iPad|iPod/i.test(navigator.userAgent)) {
return true
} else {
return false
}
}
//判断是不是安卓环境
function isAndroid() {
if (/Android/i.test(navigator.userAgent)) {
return true
} else {
return false
}
}
复制代码
watch:{
$route:{
deep: true,
immediate:true,
handler:function(value){
let vm = this
if(value.path == '/first' || value.path == '/home'){
var first = null;
mui.back = function() {
if (!first) {
first = new Date().getTime();
mui.toast('再按一次退出应用');
setTimeout(function() {
first = null;
}, 1000);
} else {
if (new Date().getTime() - first < 1000) {
plus.runtime.quit();
}
}
}
}else{
mui.back = function(){
vm.$router.go(-1)
}
}
}
}
}
复制代码