I. What is the MVVM framework
mv* includes MVC, MVP, MVVM
The MVVM framework is composed of model, View, ViewModel.
Model refers to the data, which corresponds to the JavaScript object at the front end.
View refers to views, which correspond to the DOM in the front
ViewModel observes the changes of model and view to do the update, and realizes the bidirectional binding of the data.
The front-end MVVM framework mainly includes: AngularJS, Reactjs, Vuejs
Second, the core idea of Vuejs (data-driven, modular)
1, data-driven: data two-way binding
2. Component:
Any part of the page can be a component, the page is just a container of components, a component corresponding to a Vue file, components can pass parameters, for example: A page is divided into menus, content, the bottom, you can use the menu as a component.
Third, VUE-CLI
Help to write good Vuejs code tools, help us Do directory structure, local debugging, code deployment, unloading, unit testing, etc., it is vuejs scaffolding
Installation:
Global installation: NPM install-g VUE-CLI
New project (use Webpack template here): Vue Init webpack
Then:
CD Entry Project
NPM Install dependency code base
NPM Run Dev Start service
Iv. Vue Components
<template><div @click = "ShowDetail" >Hellodiv><OtherComponent>OtherComponent>template> <style lang= "Stylus" type= "Text/stylus" >/* style */style><script type= "text/ecmascript-6" > Import Othercomponent from './components/other.vue '//import other components The export default{ //props object is a reference to the parameters that the current component may need to pass for subsequent calculation operations, Here is a numeric type parameter props: { Argu: { type:number } }, //data function, returns an object with data () that can be bound in two directions () { return{ detailshow:false } }, //computed computed property handles complex logical computed: { count () { Returnthis.argu +1 } }, //Event method methods: { showdetail:function () { This.detailshow =true } }, //Register component components:{ ' other-component ': othercomponent, } }script>
V. Basic usage of Vue-router (2.x version)
Document: http://router.vuejs.org/zh-cn/The most detailed usage also requires more reading of the document
Installation:
Adding Vue-router values to dependencies on Package.json files
Executes the NPM install command, which installs all modules according to the NPM module listed in Package.json
Use:
For example, the page Common tab switch, by clicking, in a region to switch the corresponding components
Toggle button: Router-link component as a link to a single-page routing component, it renders as a link, the To property specifies the link address
Toggle Zone: Router-view component, route matching component rendered in this area
Import the required components
VUEJS+ES6 Development mobile App real-combat project notes