Replies: 4 comments
-
The current version of Lego would be written as so: <script>
init() {
this.state = {
time: new Date()
}
this.nonReactiveTitle = "Welcome!"
}
updateTime() {
this.render({ time: new Date() })
}
</script>
<template>
<h1>${ nonReactiveTitle }</h1>
<p>Time is ${ state.time }</p>
<button @click="updateTime">update the time</button>
</template> Thumb up which version you prefer |
Beta Was this translation helpful? Give feedback.
-
Here are some counterparts we're still looking for ways to improve where the current writing may be more clear. Importing modulesConsidering we would have a Current version<script>
import { stringify } from 'utils'
const str = utils.stringify('Some String')
</script> New Setup Proposal<script import>
import { stringify } from 'utils'
</script>
<script setup>
const str = utils.stringify('Some String')
</script> Dynamic Reactive CSSCurrent version<script>
init() {
this.state = {
height: 500
}
}
</script>
<style>
section {
max-height: ${ state.height }px;
}
</style> New Setup Proposal<script setup>
const state = {
height: 500
}
</script>
<style>
section {
max-height: ${ state.height }px;
}
</style>
Accessing a Component MethodCurrent version<script>
connected() {
console.info("component is connected")
}
</script> New Setup Proposal<script setup>
this.connected = () => {
console.info("component is connected")
}
</script> |
Beta Was this translation helpful? Give feedback.
-
Here's a second option of writing <script>
import { slugify } from 'utils'
const str = slugify('The Button')
const state = { name: "world" }
function clicked(event) {
alert(`you clicked on ${event.target.name}`)
}
</script>
<template>
<h1>Hello ${ state.name }</h1>
<button @click="clicked" name="${ str }">click me to alert</button>
</template> The counterpart here is when extending native methods such as If would still be feasible with the current writing in 2 ways: 1. Defining a dedicated
|
Beta Was this translation helpful? Give feedback.
-
A new version is here : #38 |
Beta Was this translation helpful? Give feedback.
-
Following the script setup feature initiated by @echb, a new feature branch is being initiated.
Here's the new syntax offered (notice it is fully backward compatible):
A working branch is here: https://github.com/Polight/lego/tree/feature/setup.
Feel free to test, fix, improve, comment…
Beta Was this translation helpful? Give feedback.
All reactions