search

Home  >  Q&A  >  body text

javascript - In a project built with vue-cli, how to write the css or less in each .vue component externally?

For the vue-cli project, I don’t want to write the css directly in the style. I want to write it externally and import it. Should I put it in the assets or static folder?
And what files are placed in assets?

Is it okay to write it as shown in the picture? Will it have any impact after packaging?

phpcn_u1582phpcn_u15822842 days ago684

reply all(3)I'll reply

  • PHPz

    PHPz2017-05-19 10:29:39

    Modern frameworks like VUE all pursue modularity. There is no problem in writing this way. There is no problem in writing separate css in each .vue. To introduce, use import instead of src

    <srcipt>
    import 'xxx.css'
    <script>

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-05-19 10:29:39

    It is recommended to write it in assets instead of static. Static is more suitable for placing static content such as pictures, rather than css and js files coded by yourself

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-19 10:29:39

    Create a style folder, write the styles in it, and then import it. As for where to write the folder, do whatever you think is convenient. It is recommended to be at the same level as the router

    reply
    0
  • Cancelreply