vue 路由、动态路由、传参、获取参数、
1.main.js :import router from './router'2.router文件夹下建index.jsimport Vue from 'vue'import Router from 'vue-router'import Home from '@/components/Home'import DiagnosisResultData from ...
·
1.main.js :
import router from './router'
2.router文件夹下建index.js
import Vue from 'vue'
import Router from 'vue-router'
import Home from '@/components/Home'
import DiagnosisResultData from '@/Diagnosis/DiagnosisResultData'
Vue.use(Router)
export default new Router({
routes: [
{
path: '/Home',
name: 'Home',
component: Home
},
{
path: '/DiagnosisResultData',
name: '数据准备',
component: DiagnosisResultData
}
]
})
3.vue页面中:
<router-link to="/DiagnosisResultDiagnosis" id="router_to_Diagnosis_2">点我</router-link>
<router-view></router-view>
3.vue页面中动态:
<router-view></router-view>
某事件触发时,路由跳转,并传参:
this.$router.push({ //核心语句
path:'/DiagnosisResultData', //跳转的路径
query:{ //路由传参时push和query搭配使用 ,作用时传递参数
logicId:123,
}
});
4.获取传入的参数:
console.log('获取路由传的参数'); console.log(this.$router.history.current.query);
更多推荐
已为社区贡献17条内容
所有评论(0)