重复的代码在不同的方法里面 能不能抽离出去呢?

169 阅读1分钟

相同的代码可以提抽到一个函数中

methods:{
		//相同的代码可以提抽到一个函数中
		theName(){
			if(!this.loginStatus){
				uni.showToast({
					title:'请先登录',
					icon:'none'
				})
				return
			}
		},
		// 我的订单
		myOrder(){
			this.theName();
		},
		//我的学习
		myStudy(){
			this.theName();
		},
		//我的收藏
		myCollect(){
			this.theName();
		},
		// 联系客服
		customService(){
			this.theName();
		}
	}