Basic use of vue

巴扎黑
Release: 2017-06-26 11:52:13
Original
952 people have browsed it

Vue is very popular now, so today I will give you a brief introduction

What is vue?

It is based on the mvvm framework and is similar to angular. It is relatively small and easy to use.

vue official website:

vue manual website:

If you can angular, it’s great It’s easy to learn vue. Because they are basically similar

The vue command is v-xxx. Vue is composed of a piece of html code combined with json, and a new vue instance is created. Vue is developed by individuals and maintained by individuals.

vue Because of its small size, it is more suitable for mobile terminals. It is also not compatible with lower versions of IE like angular

. To use it, you must first go to the vue official website to download its library file.

Basic usage of vue:

     
//上面说了我们需要一片html代码来展示数据     {{msg}} //这样我们就完成了一条数据的基本展示   
         
Copy after login

Common instructions:

Angular has ng-model to get form element data vue gets form element data as v-model It can also perform two-way data binding with Angular.

There is ng-repeat in angular to loop the array json object. Vue is different. It uses v-for=' val in arr'. Of course, the usage is still the same just by changing the name.

The vue loop also comes with each subscript of {{$index}}. It also brings a {{$key}} which can display the key name of json

vue event:

Angular has events, of course Vue also has them. There is a difference here. Angular is ng-click. Vue is v-on:click=" fn()"

     
//上面说了我们需要一片html代码来展示数据       //v-on: 后面可以跟你任何想跟的事件。     {{msg}} //这样我们就完成了一条数据的基本展示   
         
Copy after login

v- show:

There is ng-show="true/false" in angular vue is the same as v-show="true/false" Same true shows false hide

//前边说了需要一片html代码来实现这就是我们那一片代码
Copy after login

The above is the detailed content of Basic use of vue. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn