Iconify for Vue 2 function: replaceIDs
This tutorial is part of Iconify for Vue 2 functions tutorial.
The function replaceIDs() finds IDs in SVG and replaces them with unique random IDs.
This function is meant to be used when you generate <svg> element yourself using data provided by getIcon().
Usage
The function has the following parameters:
- data, string. Icon content.
- prefix, string|function. Optional prefix for generated IDs. It can be a string or a callback that returns string.
The function returns string containing icon data with IDs replaced.
Example
This is a rather useless example. In real code, this function is used when generating SVG code samples in Icon Finder, which is not as simple as this example.
js
import { replaceIDs, getIcon } from '@iconify/vue2';
// Get icon data
const data = getIcon('carbon:deploy');
// Get content
const body = replaceIDs(data.body);
console.log('Icon content:', body);