(Or: A Series of Fortunate Nerd Snipes)
React Hooks is demoed publicly for the first time
CodeSandbox
Vue RFC #42 is proposed for
"Function-based Component API"
This is what later becomes known as
"Composition API"
(Released 2020-09-18)
New Reactivity System using Proxy Objects
Composition API and setup method
Removal of filters
Composition API
Options API
<script>
export default {
data(){
return {
count: 0,
}
},
methods:{
increment(){
this.count++;
}
},
}
</script>
<template>
<button type="button" @click="increment">
the count is {{count}}
</button>
</template>
<script>
import {ref} from 'vue';
export default {
setup(){
const count = ref(0);
const increment = ()=>count.value++
return{
count,
increment,
}
}
}
</script>
<template>
<button type="button" @click="increment">
the count is {{count}}
</button>
</template>
(Released 2020-11-25)
(Released 2021-02-16)
@vue/reactivity
(Released 2021-08-09)
Composition API
<script>
import {ref} from 'vue';
export default {
setup(){
const count = ref(0);
const increment = ()=>count.value++
return{
count,
increment,
}
}
}
</script>
<template>
<button type="button" @click="increment">
the count is {{count}}
</button>
</template>
Script Setup
<script setup>
import {ref} from 'vue';
const count = ref(0);
const increment = ()=>count.value++
</script>
<template>
<button type="button" @click="increment">
the count is {{count}}
</button>
</template>
(Released 2023-05-11)
MyCounter.vue
<script setup>
import { ref } from 'vue'
const count = ref(0)
</script>
<template>
<div>
<button @click="count++">
{{ count }}
</button>
</div>
</template>
MyCounter.js
import { toDisplayString as _toDisplayString,
createElementVNode as _createElementVNode,
openBlock as _openBlock,
createElementBlock as _createElementBlock } from "vue"
import { ref } from 'vue'
const __sfc__ = {
__name: 'App',
setup(__props) {
const count = ref(0)
return (_ctx, _cache) => {
return (_openBlock(), _createElementBlock("div", null, [
_createElementVNode("button", {
onClick: _cache[0] || (_cache[0] = $event => (count.value++))
}, _toDisplayString(count.value), 1 /* TEXT */)
]))
}
}
}
__sfc__.__file = "src/App.vue"
export default __sfc__
MyCounter.vapor.vue
<script setup>
import { ref } from 'vue'
const count = ref(0)
</script>
<template>
<div>
<button @click="count++">
{{ count }}
</button>
</div>
</template>
MyCounter.vapor.js
import { ref, effect } from "vue"
import { template, on, setText } from 'vue/vapor'
const t0 = template('<div><button>')
export default () => {
const count = ref(0)
let div = t0()
let button = div.firstChild
let _button_text
effect(()=>{
setText(button, _button_text, count.value)
})
on(button, 'click', () => count.value++)
return div
}
Slides:
https://slides.com/fimion/hackbuddy-2023-08
Twitter: @fimion - Blog: Alex.Party - Github: fimion