Blame view

pages/API/navigator/navigator.vue 2.4 KB
4b045f7c   刘淇   江阴初始化项目
1
2
3
4
5
6
7
8
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
  <template>
  	<view>
  		<page-head :title="title"></page-head>
  		<view class="uni-padding-wrap uni-common-mt">
  			<view class="uni-btn-v">
  				<button @tap="navigateTo">跳转新页面,并传递数据</button>
  				<button @tap="navigateBack">返回上一页</button>
  				<button @tap="redirectTo">在当前页面打开</button>
  				<button @tap="switchTab">切换到模板选项卡</button>
  				<button v-if="!hasLeftWin" @tap="reLaunch">关闭所有页面,打开首页</button>
  				<!-- #ifdef APP-PLUS -->
  				<button @tap="customAnimation">使用自定义动画打开页面</button>
  				<!-- #endif -->
  				<!-- #ifdef APP-PLUS || H5 -->
  				<button @tap="preloadPage">预载复杂页面</button>
  				<!-- #endif -->
  				<!-- #ifdef APP-PLUS -->
  				<button @tap="unPreloadPage">取消页面预载</button>
  				<!-- #endif -->
  				<!-- #ifdef APP-PLUS || H5 -->
  				<button @tap="navigateToPreloadPage">打开复杂页面</button>
  				<!-- #endif -->
  			</view>
  		</view>
  	</view>
  </template>
  <script>
  	const preloadPageUrl = '/pages/extUI/calendar/calendar'
  	import { mapState } from 'vuex'
  	export default {
  		data() {
  			return {
  				title: 'navigate'
  			}
  		},
  		computed: {
  			...mapState({
  				hasLeftWin: state => !state.noMatchLeftWindow
  			})
  		},
  		methods: {
  			navigateTo() {
  				uni.navigateTo({
  					url: 'new-page/new-vue-page-1?data=Hello'
  				})
  			},
  			navigateBack() {
  				uni.navigateBack();
  			},
  			redirectTo() {
  				uni.redirectTo({
  					url: 'new-page/new-vue-page-1'
  				});
  			},
  			switchTab() {
  				uni.switchTab({
  					url: '/pages/tabBar/template/template'
  				});
  			},
  			reLaunch() {
  				if (this.hasLeftWin) {
  					uni.reLaunch({
  						url: '/pages/component/view/view'
  					});
  					return;
  				}
  				uni.reLaunch({
  					url: '/pages/tabBar/component/component'
  				});
  			},
  			customAnimation(){
  				uni.navigateTo({
  					url: 'new-page/new-vue-page-1?data=使用自定义动画打开页面',
  					animationType: 'slide-in-bottom',
  					animationDuration: 200
  				})
  			},
  			preloadPage(){
  				uni.preloadPage({
  					url: preloadPageUrl,
  					success(){
  						uni.showToast({
  							title:'页面预载成功'
  						})
  					},
  					fail(){
  						uni.showToast({
  							title:'页面预载失败'
  						})
  					}
  				})
  			},
  			unPreloadPage(){
  				uni.unPreloadPage({
  					url: preloadPageUrl
  				})
  			},
  			navigateToPreloadPage(){
  				uni.navigateTo({
  					url: preloadPageUrl
  				})
  			}
  		}
  	}
  </script>