L
L
lolrofl012018-11-05 09:07:28
Vue.js
lolrofl01, 2018-11-05 09:07:28

How to get link attribute in vue?

Noob question but got stuck while learning vue. The task is simple - get the href of the clicked link. The following code is written:

<a href="{{ $paginator->nextPageUrl() }}" @click.prevent="toPage(this)"></a>

In vue:
methods: {
        toPage: function (a) {
            console.log(a);
        }
    }

Tried specifying both a.href and a.getAttribute('href') etc. But something did not work out, either undefined, or a mountain of errors in the style of "there is no such function as getAttribute ()" (strange, is it js?).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-11-05
@lolrofl01

Tried specifying both a.href and a.getAttribute('href') etc.

It would be better if you tried to read the documentation.
@click.prevent="toPage"
toPage(e) {
  console.log(e.target.href)
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question