Giter Site home page Giter Site logo

study-vue's Introduction

阅读文档

// 排序
function sort (a, b) {
    return (a - b);
}

//数组对象方法排序: 
function sortByKey(array, key) {
    return array.sort(function (a, b) {
        var x = a[key];
        var y = b[key];
        return ((x <
            y) ? -1 : ((x > y) ? 1 : 0));
    });
}

/*
    v-pre指令:
        在模板中跳过vue的编译,直接输出原始值。就是在标签中加入v-pre就不会输出vue中的data值了。
    v-cloak指令:
        在vue渲染完指定的整个DOM后才进行显示。它必须和CSS样式一起使用,
    v-once指令:
        在第一次DOM时进行渲染,渲染完成后视为静态内容,跳出以后的渲染过程。
*/

// 生命钩子
var app = new Vue({
    el: '#app',
    data: {
        count: 1
    },
    methods: {
        add() {
            this.count++;
        }
    },
    beforeCreate() {
        console.log('1-beforeCreate 初始化之前');
    },
    created() {
        console.log('2-created 创建完成');
    },
    beforeMount() {
        console.log('3-beforeMount 挂载之前');
    },
    mounted() {
        console.log('4-mounted 被挂载之后');
    },
    beforeUpdate() {
        console.log('5-beforeUpdate 数据更新前');
    },
    updated() {
        console.log('6-updated 被更新后');
    },
    activated() {
        console.log('7-activated');
    },
    deactivated() {
        console.log('8-deactivated');
    },
    beforeDestroy() {
        console.log('9-beforeDestroy 销毁之前');
    },
    destroyed() {
        console.log('10-destroyed 销毁之后');
    }
})
保存学习demo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.