pages/index/index.vue
<template>
<view class="content">
<button @click="toLogin" style="margin-top: 100px;">跳转页面</button>
</view>
</template>
<script>
export default {
data() {
return {
title: 'Hello'
}
},
methods: {
toLogin() {
uni.navigateTo({
url: '/pages/login/login'
})
}
}
}
</script>
<style>
</style>
pages/login/login
<template>
<view>
login页面
</view>
</template>
<script>
export default {
methods: {
// 禁止截屏
addFlags() {
// #ifdef APP-PLUS
let osname = plus.os.name
if (osname == "Android") {
var activity = plus.android.runtimeMainActivity()
plus.android.invoke(plus.android.invoke(activity, "getWindow"), "addFlags", 0x00002000)
}
// #endif
},
// 允许截屏
clearFlags() {
// #ifdef APP-PLUS
let osname = plus.os.name
if (osname == "Android") {
var activity = plus.android.runtimeMainActivity()
plus.android.invoke(plus.android.invoke(activity, "getWindow"), "clearFlags", 0x00002000)
}
// #endif
}
},
//这里是生命周期是页面的生命周期,在App.vue中调用请换生命周期
onUnload() {
console.log('onUnload');
this.clearFlags()
},
onLoad(option) {
console.log('onLoad');
this.addFlags()
}
}
</script>
<style>
</style>