{"title":"const symptoms = reactive({});\n const checked = reactive({});\nasync function onVisibleChange(visible) {\n if (visible) {\n const symptom = await defHttp.get({ url: '/checkItemDetail/checkItemDetail/getSymptom' });\n Object.assign(symptoms, symptom);\n }\n}\n如何使checked成为与symptoms长度一致的数组内容:您可以在onVisibleChange函数中使用Array.from方法创建一个与symptoms长度一致的数组,并将其赋值给checked。以下是您可以尝试的代码示例:\n\njavascript\nimport { reactive } from 'vue';\nimport { defHttp } from 'your-http-library';\n\nconst symptoms = reactive({});\nconst checked = reactive([]);\n\nasync function onVisibleChange(visible) {\n if (visible) {\n const symptom = await defHttp.get({ url: '/checkItemDetail/checkItemDetail/getSymptom' });\n Object.assign(symptoms, symptom);\n checked.length = Object.keys(symptoms).length;\n }\n}\n\n\n在这个示例中,我们将checked声明为一个空数组,并在onVisibleChange函数中将其长度设置为symptoms对象的键的数量。这将确保checked数组与symptoms对象的长度保持一致。

Vue.js 中使用 reactive 创建长度一致的数组

原文地址: https://www.cveoy.top/t/topic/p1xm 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录