New to Javascript and Vue, I am exploring examples to grasp the fundamental concepts.
<template>
/*<p v-bind:class="['bold', 'italic', isValid ? 'valid' : 'invalid']">*/
<p v-bind:class="classArray">
Hello, {{name[0]}} {{name[1]}}
</p>
</template>
<script>
export default {
data() {
return {
isValid: true,
name: ['John','Doe'],
classArray: ['bold', 'italic', isValid ? 'valid' : 'invalid']
}
}
}
</script>
<style>
.bold { font-weight: bolder }
.italic { font-style: italic }
.valid { color: forestgreen }
.invalid { color: crimson }
</style>
The code above triggers the following error -
ERROR [eslint] /js/vue3/src/App.vue 16:38 error 'isValid' is not defined no-undef
✖ 1 problem (1 error, 0 warnings)
How can I access 'isValid' within the classArray?