Is it possible to register a custom Vue.js component using the following code?
// register
Vue.component('my-component', {
template: '<div class="my-class">A custom component!</div>'
})
For more information, you can also visit https://v2.vuejs.org/v2/guide/components.html
I am wondering how to include CSS classes for my component.
I would expect something like:
Vue.component('my-component', {
template: '<div class="my-class">A custom component!</div>',
css: '#... my css stylesheet...'
})
However, there doesn't seem to be a css
option available.
I am aware that I could:
a) define all CSS classes in a global stylesheet or
b) use single-file Vue components (which would require a build tool supporting *.vue files. More information can be found at https://v2.vuejs.org/v2/guide/single-file-components.html)
But ideally, I would prefer to:
c) specify a CSS stylesheet for the component during registration.
=> Is this possible and if so, how can it be achieved?