javascript - vue在computed中使用$nextTick方法无法动态更新dom
伊谢尔伦
伊谢尔伦 2017-04-11 13:32:46
0
1
793

正在做自己的个人网站,需要通过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

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

모든 응답(1)
PHPzhong

set函数少了一个参数,这部分代码没有看出tagId有修改过

최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!