我不想在更改nuxt上的动态参数时恢复页面
当我在页面上时,我有一个带有两个动态参数的简单页面,更改URL参数fetch方法将再次运行。我不想要这种行为。
Fetch方法:
async fetch() {
await this.getFlightResult();
}
GetResult方法:
async getResult() {
this.$router.push({
path: `/air/${originCity?.id}-${destinationCity?.id}/${originCity?.name}-${destinationCity?.name}`,
});
await this.getFlightResult();
}
GetResultMethod:
async getFlightResult(){
const { data } = await this.$axios.get(`/api/v1/flights')
}
在更改URL参数运行Fetch方法和GetResult方法时,我有此代码,这会导致这种情况。
I have a simple page with two dynamic params when I'm on the page and changing the URL params fetch method will run again. I don't want this behavior.
fetch method:
async fetch() {
await this.getFlightResult();
}
getResult Method:
async getResult() {
this.$router.push({
path: `/air/${originCity?.id}-${destinationCity?.id}/${originCity?.name}-${destinationCity?.name}`,
});
await this.getFlightResult();
}
getResultMethod:
async getFlightResult(){
const { data } = await this.$axios.get(`/api/v1/flights')
}
I have this code when changing the URL params run fetch method and getResult method together and it causes this happen.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在不更改路径参数的情况下更改查询参数,因此,不重新呈现页面:
然后,您可以使用以下方式观看查询:
You can change the query parameters without changing the path parameter and so, not re-rendering the page:
You can then watch the queries with for example :