Detailed explanation of Vue's methods and properties

Detailed explanation of Vue's methods and properties

Vue methods and properties

1. Methods

Usage 1

methods: {
Method name: function(){},
}

Usage 2

methods: {
method name(){}
}

Notice

{ {}}Call to write()

Example

{ {aa()}}

Event triggering

@click=aa" can have () or not. If you need to pass parameters, add ()
Passing the special parameter $event can get the event object

2. Computed properties

What are computed properties?

computed

Characteristics of computed properties

  1. Computed properties have cache
  2. Computed properties are cached based on their dependencies.
  3. Computed properties are only re-evaluated when their dependencies change.
  4. When the properties that the calculated property depends on change, it will be recalculated.

Methods in computed properties

set(da)
get()

Example

 	computed:{
                 //Calculated properties//Calculated properties are cached//Directly call {{}} without writing ()
                 //When the attribute that the calculated attribute depends on changes, it will recalculate once bb(){
                    return this.arr.filter(a=>a.indexOf(this.search) > -1)
                 },
                 cc:{
                     //When the calculated property is called, the get method is automatically triggered, and when the calculated property is modified, the set method is automatically triggered set(a){
                        console.log('I am set'+"received content"+a+"received content")
                     },
                     get(){
                        console.log('I am get')
                        return this.arr.filter(a=>a.indexOf(this.search) > -1)

                     }
                 }
            },

This is the end of this article about Vue's methods and property cases. For more information about Vue's methods and properties, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed explanation of calculated properties, monitoring properties and life cycle in Vue.js
  • Summary of the use of Vue computed properties and listeners
  • Computed properties and listening properties in Vue
  • Detailed explanation of Vue's calculated properties
  • Vue computed property code example
  • Vue calculation attributes + class and style binding in Vue (recommended)
  • Vue learning notes: calculation properties and listener usage
  • Solution to Vue's calculation property not being able to monitor changes within the array

<<:  CentOS 6 uses Docker to deploy redis master-slave database operation example

>>:  How to add fields and comments to a table in sql

Recommend

Linux installation MySQL tutorial (binary distribution)

This tutorial shares the detailed steps of instal...

Summary of commonly used operators and functions in MySQL

Let’s build the data table first. use test; creat...

MySQL 5.7.15 version installation and configuration method graphic tutorial

This article shares with you a detailed tutorial ...

Detailed explanation of the marquee attribute in HTML

This tag is not part of HTML3.2 and is only suppo...

HTML table tag tutorial (33): cell vertical alignment attribute VALIGN

In the vertical direction, you can set the cell a...

uni-app WeChat applet authorization login implementation steps

Table of contents 1. Application and configuratio...

How to generate a free certificate using openssl

1: What is openssl? What is its function? What is...

mysql row column conversion sample code

1. Demand We have three tables. We need to classi...

Implement a simple data response system

Table of contents 1. Dep 2. Understand obverser 3...

How to implement input checkbox to expand the click range

XML/HTML CodeCopy content to clipboard < div s...

Example of removing json backslash in php

1. Remove backslashes through the "stripslas...

Use crontab to run the script of executing jar program regularly in centOS6

1. Write a simple Java program public class tests...

How to manage docker through UI

Docker is being used in more and more scenarios. ...