Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

chrisgrim's avatar

Is there anyway to have Vue reload a page?

I am submitting form data using the following vue code

<postreview :attributes="{{ $brand }}" inline-template v-cloak>

        <div class="panel-body">
        <div v-if="editing">
            <div class="form-group">
                <star-rating v-model="rating" :star-size="20"></star-rating>
                <textarea class="form-control" v-model="body" placeholder="Say somethijng"></textarea>

            </div>
            <button class="btn btn-xs btn-primary" @click="post">Review</button>
        </div>
        <div v-else>
            <div>
                thanks for posting!
            </div>
        </div>
    </div>

    </postreview>

and my vue file

<script>
    export default {
        props: ['attributes'],

        data() {
            return {
                editing: true,
                rating:this.attributes.rating

            };
        },

        methods: {
            post() {
                axios.post('/brands/' + this.attributes.slug + '/reviews', {
                    body: this.body,
                    rating: this.rating
                });

                this.editing = false;

                flash('Updated!');
            }
        }
    }


</script>

The issue is my page loads the rating using a foreach with laravel. So after I submit, the page won't show my new review unless I reload it. I tried looking online for a way to have Vue reload the page but I couldn't find one (which seems crazy).

Is there a way to reload the page after submitting through vue?

Thanks!

0 likes
3 replies
tykus's avatar
tykus
Best Answer
Level 104

I tried looking online for a way to have Vue reload the page but I couldn't find one (which seems crazy).

It's not really; the Vue approach would be to return the newly created resource from the API, and append it to a collection of existing resources.

Otherwise, it is javascript at the end of the day, so window.location.reload()

3 likes
bobbybouwmann's avatar

Have you tried using location.reload();. That should just reload the current page based on the url in your browser :D

Please or to participate in this conversation.