vue.js - vue 报错 Cannot read property 'children' of undefined

查看:431
本文介绍了vue.js - vue 报错 Cannot read property 'children' of undefined的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题


    <script type="text/ecmascript-6">
        import BScroll from 'better-scroll';
        const ERR_OK = 0;
        export default {
            props: {
                seller: {
                    type: Object
                }
            },
            data() {
                return {
                    goods: []
                };
            },
            created() {
                this.classMap = ['decrease', 'discount', 'special', 'invoice', 'guarantee'];
                this.$http.get('/api/goods').then((response) => {
                    response = response.body;
                    if (response.errno === ERR_OK) {
                        this.goods = response.data;
                        this.$nextTick(() => {
                            this._initScroll();
                        });
                    }
                });
            },
            methods: {
                _initScroll() {
                    this.menuScroll = new BScroll(this.$refs.menuWrapper, {});
                    this.foodsScroll = new BScroll(this.$refs.foodsWrapper, {});
                }
            }
        };
    </script>

报错:vue.common.js?e881:435 TypeError: Cannot read property 'children' of undefined

解决方案

把dom里面的ref改掉。ref="menuWrapper",ref="foodsWrapper",不要写成menu-wrapper形式就能解决问题

这篇关于vue.js - vue 报错 Cannot read property &#039;children&#039; of undefined的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆