const navigateToUrl = (key, urlParams) => { const urlParamsStr = Object.keys(urlParams).map((paramKey) => ${paramKey}=${urlParams[paramKey]}).join('&'); const url = urlParamsStr ? ${key}?${urlParamsStr} : key; url && uni.navigateTo({ url }); };

switch (key) { case 'customerVisitNum': navigateToUrl(key, { followupType: 3, timeType, employeeViewMy }); break; case 'technicalExchangeNum': navigateToUrl(key, { followupType: 1, timeType, employeeViewMy }); break; case 'liveDemonstrationNum': navigateToUrl(key, { followupType: 2, timeType, employeeViewMy }); break; case 'workPlanDay': case 'workPlanWeekly': navigateToUrl(key, { activeTabKey }); break; case 'curCustomerNum': navigateToUrl(key, { employeeViewMy }); break; case 'currentCustomerLink': navigateToUrl(key, { timeType, employeeViewMy }); break; default: url && uni.navigateTo({ url }); }

JavaScript 代码优化:简化 URL 参数拼接与导航

原文地址: https://www.cveoy.top/t/topic/mhER 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录