Having some trouble creating a functional component that displays the Feather Icons package - I'm stuck on the final step. Here's what I have so far:
This is my FeatherIcon.vue component.
<script>
const feather = require("feather-icons");
export default {
components: {},
props: {
type: {
required: true,
type: String
}
},
mounted() {},
render(createElement) {
return createElement(
"svg",
{attrs: feather.icons[this.type].attrs },
feather.icons[this.type].contents
);
}
};
</script>
In Vue documentation, it says that the 3rd argument should be either:
// {String | Array}
// Children VNodes, built using `createElement()`,
// or using strings to get 'text VNodes'. Optional.
However, the value of my 3rd argument feather.icon[this.type].contents is a string containing the "innerHTML" inside the svg tag:
"<line x1="6" y1="3" x2="6" y2="15"></line><circle cx="18" cy="6" r="3"></circle><circle cx="6" cy="18" r="3"></circle><path d="M18 9a9 9 0 0 1-9 9"></path>"
So my question is, how can I convert feather.icon[this.type].contents into a set of VNodes?
I've attempted using DOMParser and parseFromString but haven't had any success. Any suggestions?