Study notes to write the first program of Vue

Study notes to write the first program of Vue

Here we use the official document CDN

<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>

1. Write an HTML, the first Vue program

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title> 
</head>
<body>
<!--view layer template-->
<div id="app">
    {{message}}
</div>
 <!--Import vue.js-->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
 <script>
    var vm = new Vue({
        el:"#app",
        //model: data:{
            message:"hello,vue"
        }
    });
 </script>
 </body>
</html>

Note the view template and data

View

Model

ViewModel: Two-way binding means that if your front-end data changes, the data in your data will also change.

You can change the data without refreshing the page and then synchronize it to the front-end display

Decision loop

  • if
  • for

event

  • on

787 Principle

To learn Vue, we must know its 7 properties, 8 methods, and 7 instructions

el attribute

It is used to instruct the Vue compiler where to start parsing the Vue syntax, which can be said to be a placeholder.

data attribute

It is used to organize the attributes abstracted from the view. It can be said that the view data is abstracted and stored in the data.

template attribute

Used to set the template, which will replace page elements, including placeholders.

Methods Attribute

Place the business logic in the page. JS methods are generally placed in methods.

Render Properties

Creating a real Virtual Dom

computed properties

Used to calculate

watch property

watch:function(new,old){}

Monitor changes in data

Two parameters, one returns the new value, one returns the old value

The above is the detailed content of the first program of the study note vue. For more information about vue programs, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • Learn the key knowledge that must be mastered in the Vue framework
  • In-depth study of the usage and principles of Vue nextTick
  • Learn Vue component examples
  • Learn Vue.js conditional rendering
  • Learn Vue.js calculated properties
  • Simple learning vue directive

<<:  Which is faster among MySQL full-text index, joint index, like query, and json query?

>>:  Installation steps of Ubuntu 20.04 double pinyin input method

Recommend

Several ways to easily traverse object properties in JS

Table of contents 1. Self-enumerable properties 2...

Detailed explanation of MySQL precompilation function

This article shares the MySQL precompilation func...

hr horizontal line style example code

Copy code The code is as follows: <hr style=&q...

JavaScript web form function communication full of practical information

1. Introduction Earlier we talked about the front...

JavaScript to implement slider verification code

This article shares the specific code of JavaScri...

CSS3 changes the browser scroll bar style

Note: This method is only applicable to webkit-ba...

Sample code on how to implement page caching in vue mobile project

background On mobile devices, caching between pag...

How to connect to a remote server and transfer files via a jump server in Linux

Recently, I encountered many problems when deploy...

Nginx http health check configuration process analysis

Passive Check With passive health checks, NGINX a...

Detailed explanation of Linux curl form login or submission and cookie usage

Preface This article mainly explains how to imple...