提交 e2b86324 编写于 作者: 雪洛's avatar 雪洛

feat: web端使用page选择器模拟backgroundColorContent

上级 e1557994
<script lang="uts">
import { state, setLifeCycleNum } from '@/store/index.uts'
let firstBackTime = 0
export default {
globalData: {
str: 'default globalData str',
num: 0,
bool: false,
obj: {
str: 'default globalData obj str',
num: 0,
bool: false,
},
null: null as string | null,
arr: [] as number[],
mySet: new Set<string>(),
myMap: new Map<string, any>(),
func: () : string => {
return 'globalData func'
}
},
onLaunch: function () {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1000)
console.log('App Launch')
// 页面性能分析
// const performance = uni.getPerformance()
// const observer1: PerformanceObserver = performance.createObserver(
// (entryList: PerformanceObserverEntryList) => {
// console.log('observer1:entryList.getEntries()' +JSON.stringify(entryList.getEntries()))
// }
// )
// observer1.observe({
// entryTypes: ['render', 'navigation'],
// } as PerformanceObserverOptions)
},
onShow: function () {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 100)
console.log('App Show')
},
onHide: function () {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 100)
console.log('App Hide')
},
// #ifdef APP-ANDROID
onLastPageBackPress: function () {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 1000)
console.log('App LastPageBackPress')
if (firstBackTime == 0) {
uni.showToast({
title: '再按一次退出应用',
position: 'bottom',
})
firstBackTime = Date.now()
setTimeout(() => {
firstBackTime = 0
}, 2000)
} else if (Date.now() - firstBackTime < 2000) {
firstBackTime = Date.now()
uni.exit()
}
},
// #endif
onExit() {
console.log('App Exit')
},
methods: {
increasetLifeCycleNum() {
setLifeCycleNum(state.lifeCycleNum + 100)
console.log('App increasetLifeCycleNum')
}
}
}
</script>
<style>
/*每个页面公共css */
<script lang="uts">
import { state, setLifeCycleNum } from '@/store/index.uts'
let firstBackTime = 0
export default {
globalData: {
str: 'default globalData str',
num: 0,
bool: false,
obj: {
str: 'default globalData obj str',
num: 0,
bool: false,
},
null: null as string | null,
arr: [] as number[],
mySet: new Set<string>(),
myMap: new Map<string, any>(),
func: () : string => {
return 'globalData func'
}
},
onLaunch: function () {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1000)
console.log('App Launch')
// 页面性能分析
// const performance = uni.getPerformance()
// const observer1: PerformanceObserver = performance.createObserver(
// (entryList: PerformanceObserverEntryList) => {
// console.log('observer1:entryList.getEntries()' +JSON.stringify(entryList.getEntries()))
// }
// )
// observer1.observe({
// entryTypes: ['render', 'navigation'],
// } as PerformanceObserverOptions)
},
onShow: function () {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 100)
console.log('App Show')
},
onHide: function () {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 100)
console.log('App Hide')
},
// #ifdef APP-ANDROID
onLastPageBackPress: function () {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 1000)
console.log('App LastPageBackPress')
if (firstBackTime == 0) {
uni.showToast({
title: '再按一次退出应用',
position: 'bottom',
})
firstBackTime = Date.now()
setTimeout(() => {
firstBackTime = 0
}, 2000)
} else if (Date.now() - firstBackTime < 2000) {
firstBackTime = Date.now()
uni.exit()
}
},
// #endif
onExit() {
console.log('App Exit')
},
methods: {
increasetLifeCycleNum() {
setLifeCycleNum(state.lifeCycleNum + 100)
console.log('App increasetLifeCycleNum')
}
}
}
</script>
<style>
/*每个页面公共css */
@import "./common/uni.css";
/* #ifdef WEB */
/* web版暂未支持backgroundColorContent使用此样式替代 */
page {
background-color: #f8f8f8;
}
background-color: #efeff4;
}
/* #endif */
</style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册