vue router keep-alive

被包含的组件保留状态,避免重新渲染

Furong.vue

<template>
  <div id="Furong">
    <p>{{msg}}</p>
    <p>{{userInfo}}</p>
  </div>
</template>

<script>
  export default {
    name: ‘Furong‘,
    data() {
      return {
        msg: ‘hello furong!‘
      }
    },
    computed: {
      userInfo() {
        return this.$route.query;
      }
    },
    created() {
      console.log("created");
    },
    updated() {
      console.log("updated");
    },
    mounted() {
      console.log("mounted");
    },
    destroyed() {
      console.log("destroyed");
    },
    activated() {
      console.log("activated");
    },
    deactivated() {
      console.log("deactivated");
    }
  }
</script>

<style>
  #Furong {
    color: green;
  }
</style>
<template>
  <div id="app">
    <img src="./assets/logo.png">
    <router-view />
  </div>
</template>

vue router keep-alive

<template>
  <div id="app">
    <img src="./assets/logo.png">
    <keep-alive>
      <router-view />
    </keep-alive>
  </div>
</template>

vue router keep-alive

vue router keep-alive

上一篇:centos 8.3安装 一键安装部署gitlab


下一篇:八、udev配置-设置接入的U盘名字为/dev/udisk