created

在模板渲染成html前调用,即通常初始化某些属性值,然后再渲染成视图。

methods: {
            indexs:function(){
                this.$http.post('{:url("Index/fun")}')
                    .then(function(res){
                        this.items=res.data;
                        console.log(res.data);
                    })
                    .catch(function(error){
                        console.log(error);
                    });
            }
        },
        created(){
            //自动加载indexs方法
            this.indexs();
        }

mounted

在模板渲染成html后调用,通常是初始化页面完成后,再对html的dom节点进行一些需要的操作。

methods: {
            indexs:function(){
                this.$http.post('{:url("Index/fun")}')
                    .then(function(res){
                        this.items=res.data;
                        console.log(res.data);
                    })
                    .catch(function(error){
                        console.log(error);
                    });
            }
        },
        mounted(){
            //自动加载indexs方法
            this.indexs();
        }
Logo

前往低代码交流专区

更多推荐