How to inject css from vue into a django template?
I have django as backend, vue as frontend - using boilerplate from https://github.com/ilikerobots/cookiecutter-vue-django
I want to integrate quasar for my frontend. This is my setup in main.js
:
import './assets/main.css'
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import { Quasar } from 'quasar'
import App from './App.vue'
import 'quasar/dist/quasar.css'
import '@quasar/extras/material-icons/material-icons.css'
import '@quasar/extras/material-icons-outlined/material-icons-outlined.css'
import '@quasar/extras/material-icons-round/material-icons-round.css'
import '@quasar/extras/material-icons-sharp/material-icons-sharp.css'
import '@quasar/extras/material-symbols-outlined/material-symbols-outlined.css'
import '@quasar/extras/bootstrap-icons/bootstrap-icons.css'
const app = createApp(App)
app.use(createPinia()).use(Quasar, {
plugins: {}
})
app.mount('#app')
I am injecting this in my django template header.html
:
{% extends "base.html" %}
{% load vue_utils %}
{% block content %}
<div id="app"></div>
{% endblock %}
{% block inline_javascript %}
<script type="module" crossorigin src="{% vue_bundle_url 'main' %}"></script>
{% endblock inline_javascript %}
This is my vue component - App.vue
:
<template>
<q-layout view="hHh lpR fFf">
<q-header elevated class="bg-primary text-white" height-hint="98">
<q-toolbar>
<q-btn dense flat round icon="menu" @click="toggleLeftDrawer" />
<q-toolbar-title>
<q-avatar>
<img src="https://cdn.quasar.dev/logo-v2/svg/logo-mono-white.svg">
</q-avatar>
Title
</q-toolbar-title>
</q-toolbar>
<q-tabs align="left">
<q-route-tab to="/page1" label="Page One" />
<q-route-tab to="/page2" label="Page Two" />
<q-route-tab to="/page3" label="Page Three" />
</q-tabs>
</q-header>
<q-drawer show-if-above v-model="leftDrawerOpen" side="left" behavior="desktop" elevated>
<!-- drawer content -->
</q-drawer>
<q-page-container>
<router-view />
</q-page-container>
</q-layout>
</template>
<script>
import { ref } from 'vue'
console.log("HERE")
export default {
setup () {
const leftDrawerOpen = ref(false)
return {
leftDrawerOpen,
toggleLeftDrawer () {
leftDrawerOpen.value = !leftDrawerOpen.value
}
}
}
}
</script>
Looks when passed and rendered by django template: