英文:
How to use spritemap technique in Nuxt 3 application?
问题
以下是您要求的翻译部分:
I have a Nuxt 3 application and I want to use svg spritemap.
That is, put .svg files in the /assests/svg/<name>.svg
folder and use them in the application like this:
<svg>
<use xlink:href="spritemap.svg?#<name>"></use>
</svg>
I found the @nuxtjs/svg
plugin but I can't get it to work.
Connecting it as in the documentation, I get an error:
Uncaught (in promise) DOMException: Failed to execute 'createElement' on 'Document': The tag name provided ('/_nuxt/assets/svg/example.svg') is not a valid name.
How can I make a spritemap?
英文:
I have a Nuxt 3 application and I want to use svg spritemap.
That is, put .svg files in the /assests/svg/<name>.svg
folder and use them in the application like this:
<svg>
<use xlink:href="spritemap.svg?#<name>"></use>
</svg>
I found the @nuxtjs/svg
plugin but I can't get it to work.
Connecting it as in the documentation, I get an error:
Uncaught (in promise) DOMException: Failed to execute 'createElement' on 'Document': The tag name provided ('/_nuxt/assets/svg/example.svg') is not a valid name.
How can I make a spritemap?
答案1
得分: 0
在Nuxt中做这个有点困难,但是是可以的。
我在npm
上创建了一个MIT库(nuxt-svg-spritemap
)来实现这个。阅读README.md以获取更多详细信息。
英文:
It`s hard to do in Nuxt. But it's possible.
I created MIT lib on npm
(nuxt-svg-spritemap
) for this. Read README.md for more details.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论