svg-to-vue

Utility to convert SVG code into Vue component definition

MIT 9 个版本
安装
npm install svg-to-vue
yarn add svg-to-vue
pnpm add svg-to-vue
bun add svg-to-vue
README

svg-to-vue

Utility to convert SVG code into Vue component definition

Instalation

npm i svg-to-vue vue-template-compiler

yarn add svg-to-vue vue-template-compiler

Usage

const svgToVue = require('svg-to-vue');

const code = `
  <svg width="300" height="200" xmlns="http://www.w3.org/2000/svg">
    <rect width="100%" height="100%" fill="red" />
  </svg>
`;

svgToVue(code)
  .then((component) => {
    // `component` contains Vue component definition
    console.log(component);
  });

API

svgToVue(code, {
  svgoConfig: {
    plugins: [
      {
        prefixIds: true,
      },
    ],
  },
  svgoPath: 'some/path/to.svg',
});
Name Type Default value Description
svgoConfig Object/Boolean {} Configuration object passed to SVGO or false to disable optimization
svgoPath String null Path to SVG file which is used by SVGO prefixIds plugin to generate unique IDs
版本列表
0.7.0 2020-02-10
0.6.0 2019-11-11
0.5.0 2019-11-06
0.4.0-alpha.1 2018-11-25
0.4.0 2019-02-05
0.3.0 2018-10-11
0.2.1 2018-09-24
0.2.0 2018-09-24
0.1.0 2018-09-24