简体   繁体   English

在 vue 项目中将 css js 图像文件保存在哪里

[英]where to keep the css js images files in vue project

I am trying to convert an HTML template into vue project.我正在尝试将 HTML 模板转换为 vue 项目。 I am very much confused about where to keep my css js files.我对将 css js 文件保存在哪里感到非常困惑。 Whether it should be in the public directory or it should be in the src directory?是应该在public目录下还是应该在src目录下?

you can keep your CSS and Js file inside the src directory rather than public.您可以将 CSS 和 Js 文件保存在 src 目录中,而不是公开的。 public is used for keeping your static file such as static JSON, image, etc. which will not go through webpack. public is used for keeping your static file such as static JSON, image, etc. which will not go through webpack.

文件夹的基本结构

Inside src/assests paste your css, fonts and image folders like heresrc/assests assets 中粘贴您的 css、fonts 和图像文件夹,如下所示

then make sure to include them in main.js/ts eg.然后确保将它们包含在 main.js/ts 中,例如。

    import 'bootstrap'
    import 'bootstrap/dist/css/bootstrap.min.css' //boostarp
    import './assets/css/materialdesignicons.min.css'
    import './assets/css/tiny-slider.css'
    import './assets/css/style.css'
    import './assets/css/colors/default.css'

if it uses boostrap install npm install bootstrap as you will have to inlude them as I have shown above.如果它使用 boostrap 安装npm install bootstrap ,因为你必须包括它们,如我上面所示。 as per Bootstrap Doc .根据引导文档

NB: Vue3 does not support boostarp 4, and vue-boostrap use boostrap 5 instaed注意:Vue3 不支持 boostrap 4,而 vue-boostrap 使用的是 boostrap 5 instaed

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM