Vue JS 解析查询参数
Vue JS parsing query params
我可以使用
读取查询值
{{$route.query.id}}
但是我想把那个id传给另一条路线。
谁能让我做到这一点?
我试过了,但没用。
startExam(){
this.$router.push({
path:'/QuestionPaper',
query:{
id:$route.query.id
}
});
}
这是我的完整代码。我想传给试卷路线
<template lang="html">
<div class="">
<button type="button" name="button" class="btn" @click="startExam">Start Exam</button>
<h2>You have 1 hr 30 min to complete</h2>
<h2>PaperID : {{$route.query.id}}</h2>
</div>
</template>
<script>
export default {
methods:{
startExam(){
this.$router.push({
path:'/QuestionPaper',
query:{
id:$route.query.id
}
});
}
}
}
</script>
在$route前面加上这个
query:{
id:this.$route.query.id
}
我可以使用
读取查询值{{$route.query.id}}
但是我想把那个id传给另一条路线。 谁能让我做到这一点? 我试过了,但没用。
startExam(){
this.$router.push({
path:'/QuestionPaper',
query:{
id:$route.query.id
}
});
}
这是我的完整代码。我想传给试卷路线
<template lang="html">
<div class="">
<button type="button" name="button" class="btn" @click="startExam">Start Exam</button>
<h2>You have 1 hr 30 min to complete</h2>
<h2>PaperID : {{$route.query.id}}</h2>
</div>
</template>
<script>
export default {
methods:{
startExam(){
this.$router.push({
path:'/QuestionPaper',
query:{
id:$route.query.id
}
});
}
}
}
</script>
在$route前面加上这个
query:{
id:this.$route.query.id
}