get-current-pages.uvue 951 字节
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1
<template>
2 3 4 5 6
	<view>
		<page-head title="getCurrentPages"></page-head>
		<button @click="getCurrentPages">getCurrentPages</button>
		<text>{{result}}</text>
	</view>
DCloud-WZF's avatar
DCloud-WZF 已提交
7 8
</template>
<script>
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
	export default {
		data() {
			return {
				checked: false,
				result:""
			}
		},
		methods: {
			getCurrentPages: function () {
				const pages = getCurrentPages()
				let tmps ="当前页面栈中有" + pages.length.toString() + "个页面。列表如下:\n"
				for (let i = 0; i < pages.length; i++) {
					tmps = tmps + pages[i].route + "\n"
				}
				this.result = tmps
				// console.log('pages: ',pages.toString());
				// TODO 判断条件不对,需要根据自动化测试执行脚本准确验证所有栈内页面
				if (pages[0].route.includes('/tabBar/')) {
					this.checked = true
				}
				for (let i = 1; i < pages.length; i++) {
					if (pages[i].route.includes('/tabBar/')) {
						this.checked = false
					}
				}
			},
		},
	}
</script>