1

I'm using PHPStorm 2017.2 and today I faced with some trouble. Is there any way to use arrow functions within vue attributes inside template? Now, i'm getting "expression expected" error highlighted by PHPStorm, when trying to write something like

<template>
   <button @click="() => {some code... }">Click me</button>
</template>

Arrow functions works fine inside script tag, but problem with template tag drives me mad.

  • I suggest you raise a bug with Idea or the Vue plugin maintainer. There's nothing anyone here can do for you – Phil Aug 25 '17 at 04:11

2 Answers2

0

Functions are not allowed in the template syntax so if the plugin allows it or not doesn't matter anyways + its not good practice --> create a method for it much cleaner and more readable.

Git hub issue for similar problem. https://github.com/vuejs/vue-loader/issues/364

Vincent T
  • 3,044
  • 2
  • 9
  • 18
0

I'd say it's supported already in vuejs 2.0. I have tested it and it's also written in the docs:

<comp :foo="bar" @update:foo="val => bar = val"></comp>

Just PhpStorm is complaining... If you raise a bug I will upvote!

tony19
  • 125,647
  • 18
  • 229
  • 307
Amio.io
  • 20,677
  • 15
  • 82
  • 117