I have just installed the Vue Unicons module in my vue project.
Vue version: 2.6.10
Vue unicons version: 3.3.1
I am trying to create my own custom icons as explained here:
custom-icons.js:
export const myTestIcon = {
name: 'myTestIcon',
style: 'line',
viewBox: '0 0 680 680',
path: '<path d="M 635 497 l 1 -466 l -620 0 L 20 640 L 516 643 L 231 221z"></path>';
}
app.js:
import Unicon from 'vue-unicons/dist/vue-unicons-vue2.umd';
import { myTestIcon } from './custom-icons';
Unicon.add([myTestIcon]);
App.vue:
<unicon name="my-test-icon"></unicon>
Although I set viewBox
is the icon definition, the icon is rendered with default value of viewBox (0 0 24 24
).
If I add viewBox="0 0 650 650"
or even v-bind="{viewBox:'0 0 650 650'}"
to the <unicon>
element, it works fine. But I cannot do it since I use icons dynamically.
I read in this place that it might happen due to compilation, but the answer did not help me.
Any idea how can I achieve it?
CodePudding user response:
The custom icon definition schema does not include a viewBox
property, so setting it in your definition has no effect. Specifically, Vue Unicons only reads name
, style
, and path
from the custom icon definition.
The viewBox
can only be set as a prop on the <unicon>
component:
<unicon name="my-custom-icon"
viewBox="0 0 32 32"