3 ms·
Vue's version puts JavaScript-like expressions in the template though. This is what people like about JSX is that aside from from the JSX expression extension t
by spankalee 4y ago
Vue's version puts JavaScript-like expressions in the template though. This is what people like about JSX is that aside from from the JSX expression extension to JavaScript, everything else in it - binding and control flow - is actual JavaScript.
You can do better than both though by just using JS template literals, like Lit / lit-html does. Here you have only valid JS syntax, JS for the expressions, and no compiler:
html`<input
id="text"
placeholder="..."
@change=${event => setText(event.target.value) }
@keyup=${keyEvent => keyEvent.key === "Enter" && addTodo(text)}}
>`
The only non-standard bit is attribute prefixes like `@` or `.` denoting the types of bindings (event, and property, respectively).