Conditional stylesheet in Nuxt

前提是你 提交于 2019-12-19 12:02:01

问题


My CSS is not rendering well in Internet explorer even after using IE prefixes. So I want to try conditional stylesheet, but I'm not sure how to go about that in Nuxt

In Nuxt the best bet is to use CSS Conditional stylesheet in nuxt.config.js or use it in the default.vue template, but that does not fit in there since conditional stylesheet is normally applied in the head tag.

<!--[if IE]>
    <link rel="stylesheet" type="text/css" href="all-ie-only.css" />
<![endif]-->

This a typical example of what I want to try. If I can get help on how to format it so it can be used in the nuxt.config.js or in Vue component.


回答1:


You can extend the default HTML template from Nuxt.

Create a new file "app.html" at the root of your project and set your custom html template with .

see doc: https://nuxtjs.org/guide/views#document

// app.html

<!DOCTYPE html>
<html {{ HTML_ATTRS }}>
  <head {{ HEAD_ATTRS }}>
    {{ HEAD }}
    <!--[if IE]><link rel="stylesheet" type="text/css" href="all-ie-only.css"><![endif]-->
  </head>
  <body {{ BODY_ATTRS }}>
    {{ APP }}
  </body>
</html>


来源:https://stackoverflow.com/questions/58353123/conditional-stylesheet-in-nuxt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!