vue-loader@13.7.3之vue-style-loader加载一堆换行问题

vue-loader@13.7.3之vue-style-loader加载一堆换行问题,第1张

function applyToTag (styleElement, obj) {
  var css = obj.css
  // if (css && typeof css === 'string') {
  //   css = css.replace(/(\r\n|\r|\n)+/g,'');
  // }
  var media = obj.media
  var sourceMap = obj.sourceMap

  if (media) {
    styleElement.setAttribute('media', media)
  }
  if (options.ssrId) {
    styleElement.setAttribute(ssrIdKey, obj.id)
  }

  if (sourceMap) {
    // https://developer.chrome.com/devtools/docs/javascript-debugging
    // this makes source maps inside style tags work properly in Chrome
    css += '\n/*# sourceURL=' + sourceMap.sources[0] + ' */'
    // http://stackoverflow.com/a/26603875
    css += '\n/*# sourceMappingURL=data:application/json;base64,' + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + ' */'
  }

  if (styleElement.styleSheet) {
    styleElement.styleSheet.cssText = css
  } else {
    while (styleElement.firstChild) {
      styleElement.removeChild(styleElement.firstChild)
    }
    if (css.replace(/(\r\n|\r|\n|\s)*/g,'') == '') {
      styleElement.remove()
    }
    else {
      styleElement.appendChild(document.createTextNode(css))
    }

  }
}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1322441.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-12
下一篇 2022-06-12

发表评论

登录后才能评论

评论列表(0条)

保存