优化跳转,避免屎山

1.页面上通过传递标识跳转


				
				
				
			

2.js统一控制跳转路径

nextTo(index) {
				let toUrl = null
				switch (index) {
					case 1:
						toUrl = '/aboutList/focus/focus';
						break;
					case 2:
						toUrl = '';
						break;
					case 3:
						toUrl = '/SouvenirShop/shippingAddress/shippingAddress?personal=1';
						break; //钱包
					case 4:
						toUrl = '/registration/list/list';
						break;
					case 5:
						toUrl = '/aboutList/about/about';
						break;
					case 6:
						toUrl = '/login/phoneLogin/phoneLogin';
						uni.removeStorageSync('token')
						break;
					default:
						;
				}

				if (toUrl) {
					if (this.token) {
						uni.navigateTo({
							url: toUrl
						})
					} else {
							this.$cfm('你还未登录 , 请先登录', '去登录', `/login/phoneLogin/phoneLogin`)
						
					}
				}


			},

你可能感兴趣的:(前端,javascript,服务器)