이 글은 Vue에서 동적으로 라우팅 매개변수를 설정하는 사례 분석을 주로 소개합니다. 매우 훌륭하고 참고할 만한 가치가 있습니다. 필요하신 분들은 참고하시기 바랍니다.
Vue에서 라우팅 매개변수를 동적으로 설정할 수 있습니다.
1. 사용량은 항상 , 앞으로 1, 뒤로 -1, 현재 페이지: 0this.$router.go(),与js histroy.go()
<template>
<p>
<button @click="goht">后退<button> <br/>
<button @click="goqj">前进<button> <br/>
<button @click="gosx">刷新当前<button>
</p>
</template>
<script>
export default {
methods: {
goht(){
this.$router.go(-1);
},
goqj(){
this.$router.go(1);
},
gosx(){
this.$router.go(0); //或者 this.$router.go();
}
}
}
</script>2 푸시 호출 사용:
Case
<template>
<p>
<button @click="pageA">去A页面</button> <br/>
<button @click="pageB">去B页面</button> <br/>
</p>
</template>
<script>
exprot default {
methods: {
pageA(){
//去路由A页面,字符串形式只能是path,类似to="path"
this.$router.push('/RouterA');
},
pageB(){
//去路由B页面,数组形式,类似 :to="{}"
this.$router.push(
{
name: 'RouterB',
query: {'name': 'name1', title: 'title1'}
//,params:{'name': 'name2', title: 'title2'}
}
);
}
}
}
</script>vue cli를 기반으로 다중 페이지 스캐폴딩을 재구성하는 프로세스 소개
위 내용은 Vue에서 라우팅 매개변수를 동적으로 설정하는 방법 소개의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!