Detailed explanation of how to automatically refresh the page and refresh method after deleting Vue list data

Detailed explanation of how to automatically refresh the page and refresh method after deleting Vue list data

Problem description:

After the front-end deletes a piece of data or adds new data, the back-end operation is successful, but the front-end will not refresh automatically. You need to refresh the current page (use vue-router to reroute to the current page, the page will not be refreshed, and when window.reload() or router.go(0) is used to refresh, the entire browser is reloaded)

solve:

The provide / inject combination

Effect: Allows an ancestor component to inject a dependency into all its descendants, no matter how deep the component hierarchy is, and it is always effective as long as the upstream and downstream relationships are established.

(Declare the reload method to control the display or hiding of router-view, thereby controlling the reloading of the page)

App.vue code:

<template>
  <div id="app">
      <router-view v-if="isRouterAlive"></router-view>

  </div>
</template>

<script>
export default {
  name: 'App',
   components: {},
  provide(){
    return {
      reload: this.reload
    }
  },
  data() {
    return {
      isRouterAlive: true,
    };
  },
  cread() {},
  methods: {
    reload(){
      this.isRouterAlive = false;
      this.$nextTick(function(){
        this.isRouterAlive = true;
      })
    }
  },
  mounted() {
  },
}
</script>

<style>
</style>

Directions:

  // Reference vue reload method inject: ['reload'],


//Call this.reload() in the method

You must always go better and further when you are young, so as to live up to yourself and the determination behind you! come on!

Summarize

This is the end of this article about actively refreshing the page and refreshing method after deleting data in the vue list. For more relevant content about refreshing after deleting data in the vue list, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • How to handle the loss of parameters when refreshing the page when passing parameters to vue router
  • Vue router passes parameters and solves the problem of parameter loss when refreshing the page
  • Vue listens to route changes and refreshes the page in the App.vue file
  • Solve the problem of losing store data after Vue refreshes the page
  • Vue uses three methods to refresh the page

<<:  Solve the problem of yum installation error Protected multilib versions

>>:  Detailed explanation of how to upgrade software package versions under Linux

Recommend

Using puppeteer to implement webpage screenshot function on linux (centos)

You may encounter the following problems when ins...

Tutorial on downloading, installing, configuring and using MySQL under Windows

Overview of MySQL MySQL is a relational database ...

Detailed steps to install MySQL 5.6 X64 version under Linux

environment: 1. CentOS6.5 X64 2.mysql-5.6.34-linu...

Suggestions on creating business HTML emails

Through permission-based email marketing, not onl...

Bootstrap realizes the effect of carousel

This article shares the specific code of Bootstra...

Summary of related functions for Mysql query JSON results

The JSON format field is a new attribute added in...

Basic knowledge: What does http mean before a website address?

What is HTTP? When we want to browse a website, w...

MySQL uses aggregate functions to query a single table

Aggregate functions Acts on a set of data and ret...

JavaScript Advanced Programming: Variables and Scope

Table of contents 1. Original value and reference...

MySQL online log library migration example

Let me tell you about a recent case. A game log l...

Implementation of CSS3 3D cool cube transformation animation

I love coding, it makes me happy! Hello everyone,...

Upgrade MySQL 5.1 to 5.5.36 in CentOS

This article records the process of upgrading MyS...