How to use Quasar components as dynamic components?
-
What is the proper way to use Quasar components as a dynamic components, i.e.:
<component is="q-btn" />
Currently I get the following error:
Unknown custom element: <q-btn> - did you register the component correctly?
My use case is - I am creating a wrapper component to add drag-n-drop functionality so I need to be able to pass the wrapped component as a prop to my drag wrapper, which in turn uses
<component :is="tag" />
to render the actual wrapped component. -
What
importStrategy
are you using ?https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-framework
if you use dynamic components use ‘importStrategy: all’ or uncomment the line // components: [] and fill with components: [‘QBtn’, ‘QBanner’, ect]
-
importStrategy: 'auto'
Yes, if I put
'QBtn'
incomponents
then it works.So if I want to use dynamic components I have to manually put them in
components
… what an irony -
@ddenev or use
importStrategy: 'all'
-
@ddenev Auto only detects those that are in templates, you are doing dynamic, same if you use components/directives in Js files using render functions, then you’ll have to import it manually on the same file or register it normally like you did at quasar.conf.js.
-
@dobbel and @metalsadman , thank you!