Within my template, I have implemented the following code snippet:
<template>
{{ getScope(scope.row, itemIn.field) }}
</template>
For the Option API section, I've included:
methods: {
getScope(data, key) {
const str_spl = key.split(".")
if(str_spl.length == 2) {
return data[str_spl[0]][str_spl[1]]
} else {
return data[key]
}
},
}
Now, in transitioning to a Composition API
approach, I devised the following code. However, I'm encountering difficulties in returning it just like I did with the Options API
. How can I resolve this issue?
setup() {
getScope(data, key) {
const str_spl = key.split(".")
if(str_spl.length == 2) {
return data[str_spl[0]][str_spl[1]]
} else {
return data[key]
}
}
return {
getScope,
};
}