Totally stumped on this. I’m developing a WordPress plugin with Vue but I can’t get the @click event to work.
<script>
export default {
name: "App",
methods: {
showPanel: function () {
console.log("Clicked!");
}
}
};
</script>
<template>
<div id="frontend-app" class="app">
<button @click="showPanel()">Test Button</button>
<!-- <router-view /> -->
</div>
</template>
But I get the following warning and error:
runtime-core.esm-bundler.js:179 [Vue warn]: Unhandled error during execution of native event handler
at <App>
Uncaught TypeError: $options.showPanel is not a function
at onClick._cache.<computed>._cache.<computed> (App.vue?./node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/dist/templateLoader.js??ruleSet%5B1%5D.rules%5B2%5D!./node_modules/vue-loader/dist/index.js??ruleSet%5B1%5D.rules%5B8%5D.use%5B0%5D:13:59)
at callWithErrorHandling (runtime-core.esm-bundler.js:296:18)
at callWithAsyncErrorHandling (runtime-core.esm-bundler.js:304:17)
at HTMLButtonElement.invoker (runtime-dom.esm-bundler.js:437:82)
I used Vue.js 3 Plugin Generator to setup the WordPress plugin if that’s relevant and the Vue app is built with Webpack.
Any ideas? I’ve searched all over and tried everything I can think of.
Thanks