The use of VUE Foundation---->VUEJS (i)

Source: Internet
Author: User

Vue.js is a library that builds a data-driven Web interface. Its goal is to implement the data binding and the combined view components of the response through the simplest possible API, and today we start vue.js learning.

The installation and use of Vue

One, Vue's: Http://vuejs.org/js/vue.js

Second, the first example of Vue:

The structure of the project is as follows, introducing Vue.js

Vue1.html's Code:

<!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <title>Vue1</title>    <Scripttype= "Text/javascript"src=".. /vue.js "></Script></Head><Body>    <DivID= "App">        <P>{{Message}}</P>        <inputtype= "text"name= "message"V-model= "message" />    </Div>    <Scripttype= "Text/javascript"src= "Js/vue1.js"></Script></Body></HTML>

Vue1.js's Code:

var New Vue ({    ' #app ',    data: {        "Hello World"    }});

The effect of the operation is as follows:

Attention:

    • El: ' #app ' is the part that manages the ID for the app.
    • The introduction of Vue1.js is behind the page code, otherwise there will be errors in some browsers where #app elements cannot be found.

Simple use of Vue

All of the examples below are based on the above examples. Write only the added code here

One, the rendering of the list: the use of v-for

Add the following code to the <div id= "app" >:

<ul>    <li vfor = ' person in persons ' >      {{person.name}} loves {{person.love}}     </li></ul>

Add the following code to the Vue1.js data:

persons: [    ' Huhx ', Love: ' Code '},    ' Chenhui ', Love: ' book '}]

The results are as follows:

Second, processing input: the use of V-on:click

Add the following code to the <div id= "app" >:

<v-on:click= "changecontent (' Huhx ')">click on! </ Button >

Add the following code to the Vue1.js:

methods: {    function(element) {        this. Message = ' I love '+ element;    }} 

Friendship Link
    • Vue's official tutorial: http://cn.vuejs.org/guide/index.html
    • Vue's official api:http://cn.vuejs.org/api/

The use of VUE Foundation---->VUEJS (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.