I am a newbie to vue js learning from vue-mastery tutorials and I wrote a code by seeing the tutorial My code is
<template>
<div>Capacity: {{ capacity }}</div>
</template>
<script type="module">
import { ref } from "vue";
export default{
setup(){
const capacity = ref(3);
return { capacity };
}
};
</script>
I am getting the error in terminal when I run this code is "export 'ref' was not found in 'vue' And in web browser error is vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "capacity" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
found in
---> at src/App.vue
My requirement is to print capacity: 3 in the browser anyone please help me Thanks in advance!
setup()
is part of the Composition API, which is a valid structure only in Vue 3.0+ or with thevuejs/composition-api
plugin. Are you using one of those? – Augusto Moura