1👍
✅
There are two other ways you can achieve this:
- Using tenary operation
function toggle() {
isOpen.value = !isOpen.value
changeString.value = isOpen.value ? 'Ocultar Filtros' : 'Exibir Filtros'
}
- You can also use this tenary operation in
computed()
property where you compute changeString based on change inisOpen
const changeString = computed(() => isOpen.value ? 'Ocultar Filtros' : 'Exibir Filtros'
)
0👍
It sounds like changeString
should set itself based on the value of isOpen
function toggle() {
isOpen.value = !isOpen.value
if (isOpen.value) {
changeString.value = 'Ocultar Filtros'
} else {
changeString.value = 'Exibir Filtros'
}
}
Source:stackexchange.com