[Vuejs]-How to refresh the page after submit form?

1👍

One simple way to do this is to have the parent handle the communication with some events.

In the parent:

<app-filter @applied="filtersApplied"></app-filter>

and

methods: {
  filtersApplied (filters) {
    this.keyword = filters.keyword
    this.time = filters.time
  }
}

And in the AppFilter component:

submit () {
  this.$emit('applied', { keyword: this.keyword, time: this.time })
}

EDIT
I noticed you’re talking about how you’re doing the call in created(). There’s a couple solutions to that as well.

  1. You can use sub-component/nested routing, so on submit you add them as query parameters to the URL which will cause the component to re-load and created() will be called again. Check out nested routing in the Router api here
  2. You can use watchers. Since you want to know if either changes, you’ll probably want to watch a computed property which includes them both. In the AppRequest component put:computed: { combined() { this.keywords && this.time} } and watch: { combined() { makeApiRequest() } }

Leave a comment