Vue 2 Is currently written in Flow,
a static type checking system from Facebook.
Vue 3 is completely rewritten from the ground up in Typescript.
(This will make the type hints in typescript better for YOU!)
The Vue 2 source is currently is very intertwined.
The Vue 3 source will be more modular.
This is will allow for:
Vue 2 has a reactivity based on Object.defineProperty
Vue 3 will have a reactivity system Based around Proxies.
The Proxy object is used to define custom behavior for fundamental operations (e.g. property lookup, assignment, enumeration, function invocation, etc).
In other words: Fancy new JavaScript stuff
// Setting an array item by index
Vue.set(this.myArray, index, newValue)
// Adding a new property to an object
Vue.set(this.myObject, key, value)
// Deleting a property from an object
Vue.delete(this.myObject, key)
Vue 2
// Setting an array item by index
Vue.set(this.myArray, index, newValue)
// Adding a new property to an object
Vue.set(this.myObject, key, value)
// Deleting a property from an object
Vue.delete(this.myObject, key)
Vue 2
// Setting an array item by index
this.myArray[index] = newValue
// Adding a new property to an object
this.myObject[key] = value
// Deleting a property from an object
delete this.myObject[key]
Vue 3
Proxies cannot be polyfilled
in Internet Explorer.
There will be an option to do a backwards compatible build!
<template>
<div id="app">
<h1>{{ msg }}</h1>
</div>
</template>
<script>
export default {
data () {
return {
msg: 'Hello World';
},
},
};
</script>
<style>
body {
font-family: Helvetica, sans-serif;
}
</style>
<template>
<div id="app">
<h1>{{ msg }}</h1>
</div>
</template>
<script>
export default {
data () {
return {
msg: 'Hello World';
},
},
};
</script>
<style>
body {
font-family: Helvetica, sans-serif;
}
</style>
<template>
<div id="app">
<h1>{{ msg }}</h1>
</div>
</template>
<script>
export default {
data () {
return {
msg: 'Hello World';
},
},
};
</script>
<style>
body {
font-family: Helvetica, sans-serif;
}
</style>
<template>
<div id="app">
<h1>{{ msg }}</h1>
</div>
</template>
<script>
export default {
data () {
return {
msg: 'Hello World';
},
},
};
</script>
<style>
body {
font-family: Helvetica, sans-serif;
}
</style>
(Or... how i saw it)
October 25th, 2018: Dan Abramov demos React Hooks at React Conf
<template>
<button @click="increment">
Count is: {{ count }}, double is: {{ double }}
</button>
</template>
<script>
export default {
data(){
return { count: 0};
},
computed:{
double(){
return this.count * 2;
},
},
methods:{
increment() {
this.count++;
},
},
};
</script>
<template>
<button @click="increment">
Count is: {{ state.count }}, double is: {{ state.double }}
</button>
</template>
<script>
import { reactive, computed } from 'vue';
export default {
setup() {
const state = reactive({
count: 0,
double: computed(() => state.count * 2)
});
function increment() {
state.count++
}
return {
state,
increment
};
},
};
</script>
<template>
<button @click="increment">
Count is: {{ count }}, double is: {{ double }}
</button>
</template>
<script>
import { ref, computed } from 'vue';
export default {
setup() {
const count = ref(0);
const double = computed(() => count.value * 2);
function increment() {
count.value++
}
return {
count,
double,
increment,
};
},
};
</script>
Slides: https://slides.com/fimion/lets-welcome-vue-3
More information: