简体   繁体   English

在 VSCode 中预览 JavaScript 中的 SVG

[英]Preview SVG inside JavaScript in VSCode

Is it possible to preview SVG inside JavaScript in VSCode?是否可以在 VSCode 中预览 JavaScript 中的 SVG?

There are plugins that can preview SVG files in VSCode, but what if they're inside JavaScript or React components?有一些插件可以在 VSCode 中预览 SVG 文件,但是如果它们在 JavaScript 或 React 组件中呢? Or if there's a list of compound paths in an object.或者,如果对象中有复合路径列表。

There are also tools like Storybook but what if you just want to quickly preview some SVGs?还有像 Storybook 这样的工具,但是如果您只想快速预览一些 SVG 怎么办? If they're inside JS they're probably dynamic (take props like fill, color, etc), but could I then just preview them with the defaults (if provided), or a simple way to provide them props?如果它们在 JS 中,它们可能是动态的(使用填充、颜色等道具),但是我可以使用默认值(如果提供)或一种简单的方法为它们提供道具预览它们吗?

Any VSCode plugin that does that?任何 VSCode 插件可以做到这一点? How do people tackle this?人们如何解决这个问题?

I'm using this extension to preview svg files inside vscode.我正在使用这个扩展来预览 vscode 中的svg文件。

In your case, if the whole svg code is embedded in js script file, you can copy the code and paste it in an empty editor you don't need to save it, you just need to specify the type as svg then run the command Preview SVG .在您的情况下,如果整个svg代码嵌入在 js 脚本文件中,您可以复制代码并将其粘贴到一个不需要保存的空编辑器中,您只需要将类型指定为svg然后运行命令预览 SVG

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM