javascript - Registering components globally in vuejs -
i'm using webpack vuejs , i'm trying put stuff can in vendor.js app.js can smaller webpack build time can reduced.
i'm trying register font awesome vuejs version globally.
in main.js
import icon 'vue-awesome'; window.icon = icon; vue.use(icon); and in component .vue file have
<template> <icon name="beer"></icon> </template> <script> export default { components: { icon: window.icon } } </script> and getting error: unknown custom element: <icon> - did register component correctly?
window.icon set correctly can log it, think doing rookie mistake here, because when include locally in component directly working.
in module environment such commonjs, need call vue.use() explicitly
a longer discussion here: https://github.com/vuejs-templates/webpack/issues/63, gist each module must call vue.use().
Comments
Post a Comment