zoukankan      html  css  js  c++  java
  • (刷新数据 )vue中通过this.$router.push 到当前页面,只是参数不同,页面没有重新请求数据?

    //vue-router 官方demo 好像也不行
    export default {
      data () {
        return {
          loading: false,
          post: null,
          error: null
        }
      },
      created () {
        // fetch the data when the view is created and the data is
        // already being observed
        this.fetchData()
      },
      watch: {
        // call again the method if the route changes
        '$route': 'fetchData'
      },
      methods: {
        fetchData () {
          this.error = this.post = null
          this.loading = true
          // replace getPost with your data fetching util / API wrapper
          getPost(this.$route.params.id, (err, post) => {
            this.loading = false
            if (err) {
              this.error = err.toString()
            } else {
              this.post = post
            }
          })
        }
      }
    }
  • 相关阅读:
    ES6新特性总结
    Flask
    Flask
    Flask
    Flask
    Flask
    Flask
    Flask
    Linux
    Linux
  • 原文地址:https://www.cnblogs.com/dianzan/p/12617966.html
Copyright © 2011-2022 走看看