I'm trying to build a design system where users can click on various SVGs and have them set as the background of their page. They need to be able to change the colour of the SVGs so I thought I would have them as components like so:
<template>
<svg xmlns='http://www.w3.org/2000/svg'
viewBox='0 0 80 80' width='80' height='80'>
<g fill='#9C92AC' fill-opacity='0.4'>
<path d='M0 0h80v80H0V0zm20 20v40h40V20H20zm20 35a15 15 0 1 1 0-30 15 15 0 0 1 0 30z' opacity='.5'></path>
<path d='M15 15h50l-5 5H20v40l-5 5V15zm0 50h50V15L80 0v80H0l15-15zm32.07-32.07l3.54-3.54A15 15 0 0 1 29.4 50.6l3.53-3.53a10 10 0 1 0 14.14-14.14zM32.93 47.07a10 10 0 1 1 14.14-14.14L32.93 47.07z'></path>
</g>
</svg>
</template>
<script>
export default {
props: {
color: {
type: String,
default: 'black'
}
}
}
</script>
<style>
</style>
But I need to set this component as the background image of another div (the page). How could I do this? So far I tried this to no avail:
.test{
background-image:url('~/components/svg/1.vue')
}
I'm not confident that would work as I don't think Vue components can be set as backgrounds right? Any help much appreciated!
Thanks, Isaac