Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Vue.js Funkcja click
prozac2112
post 16.04.2019, 13:44:19
Post #1





Grupa: Zarejestrowani
Postów: 1
Pomógł: 0
Dołączył: 16.04.2019

Ostrzeżenie: (0%)
-----


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);
}
Go to the top of the page
+Quote Post
gitbejbe
post 18.04.2019, 15:45:22
Post #2





Grupa: Zarejestrowani
Postów: 515
Pomógł: 63
Dołączył: 27.08.2012

Ostrzeżenie: (0%)
-----


  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. }


Ten post edytował gitbejbe 18.04.2019, 15:45:40
Go to the top of the page
+Quote Post
sazian
post 18.04.2019, 18:50:49
Post #3





Grupa: Zarejestrowani
Postów: 1 043
Pomógł: 141
Dołączył: 19.09.2006
Skąd: B-tów

Ostrzeżenie: (0%)
-----


event.currentTarget
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 19.03.2024 - 02:59