Skip to content
Advertisement

Call methods of vue.js 3 single file component in script tag

Lets say i have a single file component like this:

JavaScript

is there a way to access methods(in this case ‘colorize’) outside of ‘export default’?(in this case ‘window.onload’ event

Advertisement

Answer

You can move the event listener definition to created lifecycle method, i.e. into the component definition, where you can access colorize with this.colorize:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement