Having just started learning javascript and vue.js, I encountered an issue while attempting to add a new function to an existing program.
I decided to store my new function (along with others) in a separate file:
export const MyFunctions = {
MyFunction: function(param) {
// Performing actions
}
}
After that, I imported the file into the component file and tried to call my function :
<script>
import {MyFunctions} from "@/components/MyFunctions.js";
export default {
name:"Miniature",
computed: {
useMyFunction() {
MyFunction("Please perform some actions!");
}
}
}
</script>
However, when I use the component, I receive an error message
[Vue warn]: Property or method "MyFunction" 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://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
Despite reading several resources, I can't seem to figure out why it's not working. Any help would be greatly appreciated!