跳到主要内容

plugin-svgattr

Published as @openclothes/plugin-svgattr, this plugin takes an object of key-value pairs and adds them as attributes of the <svg> tag of a pattern's SVG document on render.

Installation

npm install @openclothes/plugin-svgattr

Usage

Either add it as a part plugins in your design, or add it to a pattern instance with Pattern.use().

To import the plugin for use:

import { svgAttrPlugin } from '@openclothes/plugin-svgattr'
// or
import { svgattrPlugin } from '@openclothes/plugin-svgattr'
// or
import { pluginSvgAttr } from '@openclothes/plugin-svgattr'
// or
import { pluginSvgattr } from '@openclothes/plugin-svgattr'
提示

For convenience, this plugin is exported under mul提示le names with variations of capitalization.

Notes

To provide the attributes for the <svg> tag, you will need to pass a second argument which holds key-value pairs. It should be an Object structured as such:

{
key1: 'value1',
key2: 'value2',
key3: 'value3',
// 更多 key-value pairs can follow...
}