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

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

reply all (1)
PHPzhong

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

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!