vue2-deepob
v1.1.1
Published
Deep observable for [email protected]
Downloads
14
Readme
vue2-deepob
Deep observable for Vue 2.x , advance experience Vue3 Observeable .
Note
not support IE11
example
https://github.com/leozale/vue2-deepob/tree/master/example
Install
import Vue from "vue";
import DeepOB from "vue2-deepob";
Vue.use(DeepOB);
Demo
<template>
<div>{{ user.name }}</div>
<button @click="user.changeName()"></button>
<button @click="user.addOtherName()"></button>
<div> {{user.otherName}} <button @click="user.deleteOtherName()"> delete </button> </div>
</template>
<script>
class User{
constructor(){
this.name = "default name";
// no otherName property!!!
}
changeName(){
this.name = 'testname-'+Date.now();
}
addOtherName(){
this.otherName = "otherName!!!";
}
deleteOtherName(){
delete this.otherName; // no need Vue.delete !
}
}
new Vue({
data(){
return {
user:this.$deepob(new User())
}
}
})
</script>
License
MIT