Drukowana wersja tematu

Kliknij tu, aby zobaczyć temat w orginalnym formacie

Forum PHP.pl _ JavaScript _ Vue.js Funkcja click

Napisany przez: prozac2112 16.04.2019, 13:44:19

Mam problem, w jaki sposób mogę w Vue dostać się do atrybutów a, nawet jeśli kliknę na i.

<a href="#" v-on:click.stop.prevent="showa">
tekst <i>zdjęcie</i>
</a>




public showa(event): void{
console.log(event.target);
}

Napisany przez: gitbejbe 18.04.2019, 15:45:22

  1. public showa(event): void{
  2.  
  3. var target = event.target;
  4. var href = null;
  5.  
  6. if(event.target.tagname == 'a'){
  7. href = target.getAttribute('href');
  8. }
  9. else {
  10. href = target.closest('a').getAttribute('href');
  11. }
  12. console.log(href);
  13. }

Napisany przez: sazian 18.04.2019, 18:50:49

event.currentTarget

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)