M
M
meridbt2021-07-21 13:38:37
Vue.js
meridbt, 2021-07-21 13:38:37

What is the correct way to access static content in VUE2?

Good afternoon, dear colleagues.

I draw symbols dynamically on the SVG canvas.

I put the SVG file in the assets folder.

This is how it works:

<use xlink:href="../assets/test.svg#block1"/> // <- OK

And so the symbol is not displayed:
<use :href="'../assets/test.svg#block1'"/> // <- NOK
<use :xlink:href="'../assets/test.svg#block1'"/> // <- NOK
<use v-bind:xlink:href="'../assets/test.svg#block1'"/> // <- NOK
<use v-bind="{ 'xlink:href': '../assets/test.svg#block1' }"/> // <- NOK

If you look at the markup in the browser, in the first case the path to the file is used, after the webpack assembler, and in other cases exactly the path that is specified (non-existent)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Anton, 2021-07-21
@meridbt

require('path-to-asset')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question