js动态创建样式style

版权声明:转载请评论留言 https://blog.csdn.net/solocao/article/details/89043824

我的样式是从后台动态获取,前端进行渲染的,核心代码如下

const style = `
.vue-preview .text {
   color: #4fc08d;
 }`
this.styleEl = document.createElement('style')
this.styleEl.type = 'text/css'
this.styleEl.innerHTML = style;
document.getElementsByTagName('head').item(0).appendChild(this.styleEl)

猜你喜欢

转载自blog.csdn.net/solocao/article/details/89043824