|
This is patently not so.
Maybe if you are used to JSX. - three different html-like attributes
: and @ are just shorthand for v-bind and v-on attributes.v-bind and v-on (and v-if) accept regular javascript, and it's not just expressions... you can use `active = true` to change a data value, for instance. The only exception is v-for, as you mentioned, but it is close enough to ES6 for syntax to make sense, at least IMO. - three different scripting languages in templates (two Javascript-like, one Javascript, but only expressions)
This is splitting hairs a bit, isn't it? Apart from v-for, you can write pretty much anything you want in the other two. - one scripting language for controller/model which actually breaks JS assumptions (about what `this` is, for example) by magiacally hoisting some (but not all) properties of an object
You mean the script part of components? Do you have any examples of that? |
> accept regular javascript... The only exception is... but it is close enough to ES6
So you basically validated all I've said. And it's also incomplete. Because the amount of gotchas and things that you have to constantly keep in mind in Vue is mind-boggling compared to JSX. Because JSX is a paper-thin wrapper on top of React.createComponent, and goes out of its way to keep everything in Javascript. Unlike Vue.
Lets see your defence:
- : and @ as shorthands
It means new syntax that you have to learn, and know differences between. For all intents and purposes Vue has three different types html-like attributes. JSX has only one: javascript names.
- v-bind etc. accepting regular Javascript
Let's see how this is false:
This is not Javascript. If it was, it would assign the result of the function call to @click. It doesn't. It's a Javascript-like scripting language that has magical binding into regular Javascript.- exception is v-for, as you mentioned, but it is close enough to ES6 for syntax to make sense
So, it's not Javascript (unlike some other places where it is Javascript), and it's not ES6 syntax, but it's "close enough to ES6". So it's not. It's a different Javascript-like scripting language.
The only place where Vue allows regular unadulterated Javascript is inside curly braces: {{}}. And there it only allows expressions (Note: JSX also only allows expressions inside curly braces).
However. Even there it's not Javascript. Not really:
Valid Vue. Invalid Javascript.- You mean the script part of components? Do you have any examples of that?
Of course. See inline comments. Example from here: https://vuejs.org/v2/examples/tree-view.html