Vue3 - Reactivity

목차

Reactivity

Proxy

set

  • target
    • 객체
  • property
    • 객체내 속성
  • value
    • 전달 받는 값
<div id="app">

</div>
<!-- <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> -->
<script>
var data = {
message: 10
}

function render(sth) {
var div = document.querySelector('#app');
div.innerHTML = sth;
}

var app = new Proxy(data, {
get() {
console.log('값 접근')
},
set(target, prop, value) {
console.log('값 갱신')
target[prop] = value
render(value)
}
})
</script>
app.message = 'hello vue';
Share