Level 50
i am not proficient in Vue (sorry about that), but something like this doesn't work?
let componentLoaded = false;
watchEffect(() => {
if (componentLoaded) {
//...
} else {
componentLoaded = true;
}
});
thats what came to my mind, but here is a suggestion from AI to use watch() instead, is it of any use?
import { watch } from 'vue'
watch(
() => student.value.path_id,
(newVal, oldVal) => {
if (oldVal === undefined) {
return;
}
apiProject.index(newVal).then(response => {
projects.value = response.data.projects
if (newVal == savedPathId.value) {
student.value.project_id = savedProjectId.value
} else {
student.value.project_id = projects.value[0].id
}
})
}
)
1 like