vue在computed中使用$nextTick方法无法动态更新dom

正在做自己的个人网站,需要通过url参数的变化来动态更新页面内容,根据教程写了这样的代码,但却达不到想要的效果。vue框架是1.0版本的,在项目中使用了vue-router和vue-infinite-loading

代码如下:

  computed: {
    tagId: {      get: function () {        return this.$route.params.tag
      },      set: function () {        this.list = []        this.$nextTick(() => {          
      this.$broadcast('$InfiniteLoading:reset')
        })
      }
    }
  },
  methods: {
    onInfinite () {      
    this.$http.get('artical-list/tag/' + this.tagId + '/page/' + (this.list.length / 10 + 1)).then((res) => {        
    if (res.data.length) {          this.list = this.list.concat(res.data)          
    this.$broadcast('$InfiniteLoading:loaded')
        } else {          this.$broadcast('$InfiniteLoading:complete')
        }
      })
    }
  }

求解,谢谢!

附:vue-infinite-loading的文档:
https://peachscript.github.io...!/getting-started/with-filter


慕桂英4014372
浏览 2310回答 1
1回答

万千封印

set函数少了一个参数,这部分代码没有看出tagId有修改过
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript