const app = getApp(); const route = { Course:{ Exercise:"{exercise_cover}?exercise_id=${container_id}", HomeworkCommon:"{course}?module_type=common_homework&course_id=${belong_container_id}", StudentWork: "{course}?module_type=common_homework&course_id=${belong_container_id}", } } Component({ properties: { data:Object }, data: { eduImgDir:global.config.eduImgDir }, methods: { enterDetail(){ let {data} = this.data; try{ var url = route[data.belong_container_type][data.container_type]; }catch(e){ return; } if(!url) return; console.log(url); url = url.replace(/\$\{(.*?)\}/g,function(match, name){ return data[name]||''; }); app.navigateTo({url}); } } })