# toRef可以将对象的属性变为响应式的 ![](https://img2020.cnblogs.com/blog/1943889/202112/1943889-20211209125959862-792437108.png)
<script>
import { reactive,toRefs } from '@vue/reactivity'
export default {
name: 'Demo',
setup(){
let person = reactive({
name:'蔡恒',
age:28,
job:{
salary:20
}
})
// toRef的使用
// return {
// name:toRef(person,'name'),
// age:toRef(person,'age'),
// salary:toRef(person.job,'salary')
// }
// toRefs 的使用
return {
...toRefs(person)
}
// return {
// name:person.name,
// age:person.age,
// salary:person.job.salary
// }
}
}
</script>