1

How to listen a click on a vuikit icon ?

So this is how we are supposed to listen for a native click event Vue v-on:click does not work on component but that doesn't seem to work for the icons in https://vuikit.js.org/ has anyone faced this?

Given:

<template>
<div>
  <div><vk-icons-cog v-on:click.native="onClick"></vk-icons-cog ></div> // doesn't work
  <test-cmp v-on:click="onClick"></test-cmp> // works
</div>
</template>
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
code4jhon
  • 5,725
  • 9
  • 40
  • 60

1 Answers1

1

I am not sure whether it is what you want, but the code below works for me.

<vk-icon icon="cog" v-on:click="onClick"></vk-icon>

https://codesandbox.io/s/kkn095v0qv

choasia
  • 10,404
  • 6
  • 40
  • 61
  • awesome, seems to be related to the instantiation then. //doesn't work // works – code4jhon Jul 06 '18 at 01:04
  • I added this question regarding instantiation https://stackoverflow.com/questions/51201826/error-instantiating-a-viukit-icon – code4jhon Jul 06 '18 at 01:16
  • 1
    Umm.. maybe it is related to the version? I used the latest version and both worked for me... – choasia Jul 06 '18 at 02:47
  • Ohh, you mean they both render ... yeah and you are right I just checked the version of my vuikit library and it's not the latest, testing it with the version I'm using also fails on the sandbox. Thanks – code4jhon Jul 06 '18 at 04:21
  • Yeah, that is what I mean. Sorry for the misleading word – choasia Jul 06 '18 at 04:23