没有用reactive包裹的非响应式数据,为什么也具有响应式
老师你好,没有用reactive包裹的非响应式数据,为什么也具有响应式,我点击按钮修改数据 ,页面也会跟着改变。
<template>
<div class="wrapper">
<div class="data" v-for="item in state.todoList" :key="item">state:{{item}}</div>
<div class="data" v-for="item in objdata.objlist" :key="item">objdata:{{item}}</div>
<el-button @click="handleClick">change</el-button>
</div>
</template>
<script>
import {reactive} from 'vue'
export default {
name:'TestResponse',
setup(){
const state = reactive({
todoList:['打牌','game','test']
})
const objdata = {
objlist:['obj','dfe']
}
const handleClick = () => {
state.todoList.push('music')
objdata.objlist.push('kkk')
}
return {state,objdata,handleClick}
}
}
</script>
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星