Why register a plugin and use methods in components that do not have this plugin #13124
Unanswered
qq88310566
asked this question in
Help/Questions
Replies: 1 comment
-
For Composition API, we recommend using |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
register plugin clickStat
app.use(clickStat).mount('#app');
clickStat plugin
export default { install(app, options) { app.config.globalProperties.$clickStat = (key = '', opt = {}) => { console.log('clickStat', key); }; }, };
want to use in component
<h3 @click="handleClick">test</h3>
const handleClick = ()=>{ $clickStat() }
but result is
runtime-core.esm-bundler.js:268 Uncaught ReferenceError: $clickStat is not defined
at handleClick (index.vue:246:3)
Beta Was this translation helpful? Give feedback.
All reactions