Vue.js 中使用 toRefs 将数据转换为响应式对象
import { toRefs } from 'vue';
export default { components: {}, data() { // 这里存放数据 return { info: JSON.parse(JSON.stringify(this.modalInfo)), }; }, props: { modalInfo: { type: Object, default: () => {} } }, watch: { modalInfo() { this.info = JSON.parse(JSON.stringify(this.modalInfo)) } }, computed: { ...toRefs(this.info) }, methods: { // 这里存放方法 closeModal() { this.$emit('close-modal'); }, submitModal() { this.$emit('submit-modal', this.info); } } };
原文地址: https://www.cveoy.top/t/topic/kHev 著作权归作者所有。请勿转载和采集!