How does vuejs refresh the current route?

clipboard.png

clipboard.png

for example, how do I initialize this component when I click to bill successfully? Just go back to where you just came in?
there are a lot of things here. I don"t want to find the corresponding binding value and empty it. I thought of this way to do this.$router.push ("/-sharp") in the first place.
but it"s useless.


good question, Baidu learned after.
https://www.zhihu.com/questio.

if you simply want to reinitialize a specific component, you can use v-if to control it in the parent component.

<div>
  <child-comp v-if="showChild"></child-comp>
</div>

// 
refreshChild() {
  this.showChild = false;
  setTimeout(() => {
    this.showChild = true;
  }, 0);
}

the outermost layer of the component plus ref to clear through ref


all your bound values should be written in an object. If you empty the object directly after billing, you will return to the original value


.

can't you use this.$router.go (0)?
this is what I usually write


this.$message('')


setTimeout(() => {
  this.$router.go(0)
}, 500)



this.$nextTick( () => {
this.$router.go(0)
})

it feels good to use it!


look at your UI, using element, right? There is a reset method for form forms in element, which is to empty the data and determine the conditions. You can learn about the resetFields () method. When this method is called, the form is restored to its original value.

<template>
  <div>
    <el-form :model="formData" ref="formData" label-width="80px">
      <el-form-item label="" prop="name">
        <el-input v-model="formData.name" placeholder=""></el-input>
      </el-form-item>
      <el-form-item label="" prop="mobile">
        <el-input v-model="formData.mobile" placeholder=""></el-input>
      </el-form-item>
    </el-form>
    <el-button @click="onReset" type="primary"></el-button>
  </div>
</template>

<script>
export default {
  data () {
    return {
      formData:{
          name:'',
          mobile: ''
      }
    }
  },
  methods:{
    onReset(){
        this.$refs['formData'].resetFields();
    }
  }

}
</script>

after entering:

clipboard.png

:

clipboard.png


detected, the current route can be refreshed.

this.$router.go(0);
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e88b75-46cde.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e88b75-46cde.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?