• Vue 命令


    1、脚手架Cil搭建

    全局安装 npm: npm install -g vue-cli

    创建项目:vue init webpack vueapp(项目名称)

    下载路由模块: npm install vue-router --save  (vue-router为路由名称)

    安装http : npm install vue-resource --save

    安装json-server:npm install -g json-server

    https://github.com/typicode/json-server(json-server   官网)

    2.http请求

    export default {
            name: "customers",
            data() {
                return {
                    customers: []
                }
            },
            methods: {
                fetchCustomers() {
                    this.$http.get("http://localhost:3000/users")
                        .then(function (response){
                            this.customers = response.body
                        })
                }
            },
            created() {
                this.fetchCustomers()
            }
        }

     3、钩子函数

    beforeCreate: function() {
        alert("组件实例化之前执行的函数");
    },
    created: function() {
        alert("组件实例化之完毕但页面还未显示");
    },
    beforeMount: function() {
        alert("组件挂在前,页面扔未展示,但虚拟DOM已经配置");
    },
    mounted: function() {
        alert("组件挂在后,此方法执行后,页面显示");
    },
    beforeUpdate: function() {
        alert("组件更新前,页面扔未更新,但虚拟DOM已经配置");
    },
    updated: function() {
        alert("组件更新后,此方法执行后,页面显示");
    },
    beforeDestory: function() {
        alert("组件销毁前");
    },
    destory: function() {
        alert("组件销毁");
    }
  • 相关阅读:
    Java基础教程(15)--枚举类型
    Java基础教程(14)--嵌套类
    Java基础教程(13)--包
    Java基础教程(12)--深入理解类
    Java基础教程(11)--对象
    Java基础教程(10)--类
    Java基础教程(9)--流程控制
    Java基础教程(8)--表达式、语句和块
    Java基础教程(7)--运算符
    Java基础教程(6)--数组
  • 原文地址:https://www.cnblogs.com/hhj3645/p/9488645.html
Copyright © 2020-2023  润新知