Home Web Front-end JS Tutorial How to make Vue2.0 make radio selection mutually exclusive

How to make Vue2.0 make radio selection mutually exclusive

Apr 28, 2018 pm 01:50 PM
mutually exclusive Single choice

This time I will show you how to make Vue2.0 make single selection mutually exclusive. What are the things to pay attention to when Vue2.0 makes single selection mutually exclusive? The following is a practical case. Let’s take a look. one time. This article introduces the method of implementing radio selection mutual exclusion in Vue2.0 and shares it with everyone. The details are as follows:

Needs to implement the function as shown above

1. When loading the page for the first time, highlight the corresponding option according to the catgoryId in the data

2. Click on an option, the option will be highlighted, and the highlighting will be removed for others


Code structure:

<template> 
  <dd @click="changeCategory(currCourseFirst.categoryId)" 
        v-for="currCourseFirst in currCourse.currCourseFirst" 
        :key="currCourseFirst.categoryId" 
        :class="resultCategoryId === currCourseFirst.categoryId ? &#39;active&#39;: &#39;&#39;" >
          {{currCourseFirst.name}}
  </dd>
</template>
<script>
  export default{
    data() {
      return {
        categeryId: this.$route.query.categoryId,
        typeId: this.$route.query.typeId
      }
    },
    methods: {
      changeCategoryId(categoryId) {
        this.categoryId = categoryId
      }
    },
    computed: {
      resultCategoryId(){
        return this.categoryId
      }
    }
  }
</script>
Copy after login

Self-understanding

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

Detailed explanation of the use of commonly used components in vue


What are the methods for operating render execution

The above is the detailed content of How to make Vue2.0 make radio selection mutually exclusive. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1658
14
PHP Tutorial
1257
29
C# Tutorial
1231
24
How to implement multi-select, radio-select and other form components in Vue? How to implement multi-select, radio-select and other form components in Vue? Jun 25, 2023 pm 09:49 PM

Vue is a popular front-end framework that provides a rich component library to facilitate the development of various types of applications. In actual development, form components are one of the components we often use and process. In this article, we will study how to implement multi-select, radio-select and other form components in Vue. 1. Multi-select components In Vue, we can use the v-model directive to implement two-way binding of form controls. For multi-select components, we can use multiple checkboxes to achieve this. Below is a basic multi-select component representation

Implementation of mutual exclusion and critical section of C++ functions in concurrent programming? Implementation of mutual exclusion and critical section of C++ functions in concurrent programming? Apr 28, 2024 am 08:42 AM

In concurrent programming, mutexes and critical sections are used to prevent data races. Mutex is a data structure that allows only one thread to access shared resources at a time. The specific implementation is as follows: Define a Mutex class with atomic tags. Use the test_and_set() method to lock and the clear() method to unlock. The critical section is a section of code that can only be executed by one thread at a time. The specific implementation is as follows: declare a mutex. Use the lock_guard wrapper to access shared resources in critical sections.

How to handle multi-thread synchronization and mutually exclusive access in C# development How to handle multi-thread synchronization and mutually exclusive access in C# development Oct 08, 2023 pm 05:57 PM

How to handle multi-thread synchronization and mutually exclusive access in C# development requires specific code examples. In C# development, the use of multi-threads can improve the concurrency and performance of the program. However, concurrent execution of multiple threads may also cause some problems, such as data competition and resource conflicts. To solve these problems, we need to use synchronization and mutual exclusion mechanisms to ensure correct cooperation between threads. Synchronization refers to the execution of multiple threads in a certain order to ensure the cooperative relationship between threads. Mutual exclusion means that only one thread is allowed to access a shared resource at the same time.

How to deal with multi-thread synchronization and mutual exclusion issues in C# development How to deal with multi-thread synchronization and mutual exclusion issues in C# development Oct 10, 2023 pm 03:42 PM

How to deal with multi-thread synchronization and mutual exclusion issues in C# development requires an overview of specific code examples: In C#, the use of multi-threading has become a common development requirement. However, since multiple threads operating shared resources simultaneously may cause data inconsistency or conflicts, synchronization and mutual exclusion mechanisms need to be used to solve these problems. This article will introduce how to deal with multi-thread synchronization and mutual exclusion issues in C# development, and provide specific code examples. The concept of thread synchronization When multiple threads operate shared resources at the same time, data inconsistencies or conflicts may occur.

Java thread synchronization and mutual exclusion: starting from scratch, creating efficient concurrent programs Java thread synchronization and mutual exclusion: starting from scratch, creating efficient concurrent programs Feb 19, 2024 pm 11:09 PM

:Overview of Java Thread Synchronization and Mutual Exclusion In Java, thread synchronization and mutual exclusion are techniques to ensure that data races or other inconsistencies do not occur when multiple threads share data. Thread synchronization means that when multiple threads access shared data, they coordinate their access through some mechanism to ensure the consistency and integrity of the data. Thread mutual exclusion means that only one thread can access shared data, and other threads can only wait. Java Thread Synchronization Mechanism Java provides a variety of thread synchronization mechanisms, the most common of which are locks and monitors. Locks are a low-level synchronization mechanism that allows a thread to acquire a lock before entering a critical section (that is, the block of code where shared data is located) and release the lock after exiting the critical section. The monitor is an advanced synchronization

Java thread synchronization and mutual exclusion: let your program dance in the concurrent world Java thread synchronization and mutual exclusion: let your program dance in the concurrent world Feb 19, 2024 pm 07:33 PM

In computer science, concurrent programming is when a program can perform multiple tasks simultaneously. It is often used to fully utilize the computing power of multi-core processors and plays an important role in areas such as user interface, network communication, and database operations. However, concurrent programming also brings some challenges, the most important of which is how to ensure data consistency and program correctness when multiple threads access shared resources simultaneously. Java provides rich thread synchronization and mutual exclusion mechanisms to help developers solve challenges in concurrent programming. These mechanisms mainly include locks, atomic operations and the volatile keyword. Locks are used to protect shared resources. They allow one thread to monopolize a shared resource when accessing it, preventing other threads from accessing it at the same time, thus avoiding data inconsistency and program crashes.

Getting Started with PHP: Synchronization and Mutual Exclusion Getting Started with PHP: Synchronization and Mutual Exclusion May 21, 2023 am 08:10 AM

With the continuous development of the Internet, PHP, as a major server-side scripting language, is favored by more and more developers. In programs written in PHP, synchronization and mutual exclusion issues often need to be considered. This article will introduce you to the synchronization and mutual exclusion mechanisms in PHP from an entry-level perspective. 1. What is synchronization and mutual exclusion? Before understanding synchronization and mutual exclusion, we need to first understand the concept of concurrency. The so-called concurrency refers to the simultaneous execution of multiple threads within the same time period. These multiple threads may cause resource competition issues.

Peterson diagram problem in C program Peterson diagram problem in C program Aug 26, 2023 am 11:01 AM

Suppose we have a graph as shown below. This graph is a Peterson diagram. Vertices are numbered from 0 to 9. Each vertex has some letters. Consider a walk W on this graph using L vertices. When the letter sequence in walking W is the same as S, the string S is realized by walking W. We can visit a vertex multiple times. For example, a string S is similar to "ABBECCD", which is achieved by walking (0,1,6,9,7,2,3). Our task is to find such a walk and, if such a walk exists, find the lexicographically smallest walk. If there is no such walk, -1 is returned. Algorithm petersonGraphWalk(S,v)-begin &

See all articles