Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

vue v-on:click

<div id="example-3">
  <button v-on:click="say('hi')">Say hi</button>
  <button v-on:click="say('what')">Say what</button>
</div>
Comment

click in vue

<button  @click="setComponent('manage')">manage</button>
Comment

vue @click

// ...
<button v-on:click="warn('Форма не может быть отправлена.', $event)">
  Отправить
</button>
//...

methods: {
  warn: function (message, event) {
    // теперь у нас есть доступ к нативному событию
    if (event) {
      event.preventDefault()
    }
    alert(message)
  }
}
Comment

click on item in v-for vue

<template>
  <div id="accordion" class="accordion-container">
    <div
      v-for="(item, index) in items"
      :key="index"
      :class="[
        'accordion',
        { 'is-open': isOpen.includes(index) }
      ]"
    >
      <div class="accordion-header" @click="toggleAccordion(index)">
        {{ item.title }}
        <i v-if="!isOpen.includes(index)" class="fal fa-plus"/>
        <i v-else class="fal fa-minus"/>
      </div>
      <div class="accordion-body">
        <div class="accordion-content">
          {{ item.text }}
          <strong>{{ item.sub }}</strong>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "trial-page",
  data() {
    return {
      items: [
        {
          title: "Accordion 1",
          text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
          sub: "Pellentesque risus mi"
        },
        {
          title: "Accordion 2",
          text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
          sub: "Pellentesque risus mi"
        },
        {
          title: "Accordion 3",
          text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
          sub: "Pellentesque risus mi"
        }
      ],
      isOpen: []
    };
  },
  methods: {
    toggleAccordion(index) {
      if (this.isOpen.includes(index)) {
        this.isOpen = this.isOpen.filter(i => i !== index);
        return;
      }

      this.isOpen.push(index);
    }
  }
};
</script>

<style>
.accordion:not(.is-open) .accordion-body {
  display: none;
}
</style>
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to close a form c# 
Csharp :: how to create public variable in c# 
Csharp :: unity reference textmeshpro 
Csharp :: unity get component in parent 
Csharp :: Edit file C# 
Csharp :: add row and columns to grid wpf in code 
Csharp :: how to make a string in c# 
Csharp :: append 2 arrays c# 
Csharp :: list min and Max value in c# 
Csharp :: windows forms get all images from resources 
Csharp :: first person mouse look unity 
Csharp :: Kill System Process in C# 
Csharp :: data annotations in asp.net core 
Csharp :: if c# 
Csharp :: unity vector3 to array 
Csharp :: how to set border for groupbox in c# 
Csharp :: C# actions 
Csharp :: print a file from C# 
Csharp :: c# override gethashcode 
Csharp :: c# catch multiple exception types 
Csharp :: callling class c# 
Csharp :: c# move form without border 
Csharp :: unity master volume changer 
Csharp :: c# list add to list 
Csharp :: cast from object to generic type c# 
Csharp :: convert list string to list enum c# 
Csharp :: c# setting window size 
Csharp :: c# validate xml 
Csharp :: private Vector3 direction; 
Csharp :: C# one line method 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =