vue视图不更新问题

export default {
        data () {
            return {
                items: [],
                recPics16: [],
                pagesize: 12,
                pages: 0
            };
        },
        created () {
            this.getData();
        },
        methods: {
            getData () {
                let sno = this.$route.params.ss;
            let _this = this;
                this.$http.get('http://app.isfunweb.com/web/app/query.do', {params: {'key': '8a45608c16c76ef9f4a56b12e3f238be', 'pageSize': '98', 'a_no': '001', 'classify': '01', 's_no': sno}}).then((res) => {
                _this.items = res.body.result;
                console.log(_this.items.length);
            }, (err) => {
                console.log(err);
            });
            },
            currentpage (p) {
                this.recPics16 = this.items.slice(p * this.pagesize - 12, p * this.pagesize);
                console.log(this.recPics16);
            }
        },
        components: {
            item8
        },
        watch: {
            '$route': 'getData'
        }

    };

监听路由变化发送Ajax请求,数据都更新了,但视图怎么没更新。。。。

阅读 7.9k
3 个回答

不要直接给数组赋值,用push或concat试试,_this.items.push

Vue无法检测求组本身的覆盖事件。需要调用对应的变异方法,比如push shift等才能生效

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题