Implementation of Vue counter

Implementation of Vue counter

1. Implementation of counter

Simply implement a counter on the page:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/vue.js"></script>
</head>
<body>
<div id="app">
  <h3>Current counter: {{counter}}</h3>
  <button @click="add">+</button>
  <button @click="minutes">-</button>
</div>
<script>
  const app = new Vue({
    el: "#app",
    data: {
      counter: 0
    },
    methods: {
      add: function () {
        this.counter++;
      },
      minutes: function () {
        this.counter--;
      }
    }
  })
</script>
</body>
</html>

2. Achieve results

The final effect is shown in the gif below:

This is the end of this article about the implementation of Vue counter. For more relevant Vue counter content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Vue implementation counter case
  • Vue implements simple production of counter
  • Create a PC-side Vue UI component library from scratch (counter component)
  • Vuex usage and simple example (counter)
  • Vuex implements counter and list display effects
  • Vuex implements a simple counter

<<:  CSS flex several multi-column layout

>>:  How to configure redis sentinel mode in Docker (on multiple servers)

Recommend

Introduction to several ways to introduce CSS in HTML

Table of contents 1. Embed CSS styles directly in...

Discussion on the Issues of Image Button Submission and Form Repeated Submission

In many cases, in order to beautify the form, the ...

Detailed explanation of HTML's <input> tag and how to disable it

Definition and Usage The <input> tag is use...

The implementation of Youda's new petite-vue

Table of contents Preface Introduction Live Easy ...

How to delete garbled or special character files in Linux

Due to encoding reasons, garbled characters will ...

Analysis of mysql view functions and usage examples

This article uses examples to illustrate the func...

Example usage of Linux compression file command zip

The ".zip" format is used to compress f...

Summary of problems that may occur when using JDBC to connect to Mysql database

First, clarify a few concepts: JDBC: Java databas...

Node.js makes a simple crawler case tutorial

Preparation First, you need to download nodejs, w...

Encapsulate a simplest ErrorBoundary component to handle react exceptions

Preface Starting from React 16, the concept of Er...