Answer the question
In order to leave comments, you need to log in
How can you simplify the work with the object?
In the example below, I can't access the properties of an object by substituting the key in square brackets components.value[key] = true; unless I create a separate variable for the object and set it to type [key: string]: boolean
const componentsObj: {
[key: string]: boolean
} = {
'core-preloader': false,
'core-button': false,
'core-progress': false,
'core-alert': false,
'core-toggler': true,
}
const components = ref(componentsObj);
function toggleComponent(key: string) {
components.value[key] = true;
}
const components = ref( {
'core-preloader': false,
'core-button': false,
'core-progress': false,
'core-alert': false,
'core-toggler': true,
});
function toggleComponent(key: string) {
components.value[key] = true;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question