Giter Site home page Giter Site logo

vue-manual's Introduction

Vue Manual

Table of Contents

Why Vue

  • Easy to learn
  • Easy to use
  • Easy to maintain
  • Fast

What Vue offers

  • Reactive Interfaces
  • Declarative Rendering
  • Data Binding
  • Directives
  • Template Logic
  • Components & Nesting
  • Event Handling
  • Computed Properties
  • CSS Transition & Animation
  • Custom Filters

Using vuejs

  • Include the <script> tag in an html file
  • Install via npm & create webpack config
  • Use the vue-cli tool along with webpack
  • Install using the Bower client side package manager
  • Using in the Laravel via laravel-mix

Addtional Tools & Plugins

  • vue-router - Official router deeply integrated with Vue.js core
  • vue-resource - Handle web requests
  • vue-async-data - Async data loading
  • vue-validator - Form validation plugin
  • vue-dev-tools - Chrome devtools extension
  • vue-touch - Touch gestures using Hammer.js
  • vuex - Vuex is a state management pattern + library

Reactive

function createReactiveObject(obj) {
  const keys = Object.keys(obj);
  obj.$data = Object.assign({}, obj);
  keys.forEach(key => {
    Object.defineProperty(obj, key, {
      get: reactiveGetter.bind(obj, key),
      set: reactiveSetter.bind(obj, key)
    });
  });
}

function reactiveSetter(property, value) {
  this.$data[property] = value;
  console.log(`${property} changed to ${value}`);
}

function reactiveGetter(property) {
  console.log(`get ${property}`);
  return this.$data[property];
}

let user = {
  name: "",
  score: 0
};

createReactiveObject(user);

user.name = "Changed";

Declarative Rendering

html

<div id="app">
  Mustache: {{ message }}
</div>

javascript

var app = new Vue({
  el: "#app",
  data: {
    message: "Hello Vue!"
  }
});

Component Lifecycle

- creation
  * beforeCreate
  - Initialize State
  * created
===== Complie Template =====
- mounting
  * beforeMount
  - Create Virtual Dom
  * mounted
===== Listen for Data Changes =====
- updating
  * beforeUpdate
  - Re-Render Virtual DOM and patch
  * updated
===== When vm.$destroy() is called =====
- detroy
  * beforeDestroy
  - Teardown Virtual DOM
  * destroyed

Data and methods

html

<div id="app">
  <input type="text" v-on:input="changedName">
  <p>{{name}}</p>
</div>

javascript

new Vue({
  el: "#app",
  data: {
    name: ""
  },
  methods: {
    changedName(event) {
      this.name = event.target.value;
    }
  }
});

vue-manual's People

Contributors

yuttasakcom avatar

Watchers

 avatar

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.