** 1. 划分目录结构**
- 在assets文件夹内创建imgs和css文件夹,用于存放图片和样式
- 在components文件夹中创建common和content文件夹;common用于存放共同的组件,以后可以重复利用的,content文件夹中存放与内容相关的组件
- 创建views文件夹,用于存放页面文件
- 创建router文件夹,存放路由
- 创建store文件夹,用于存取状态
- 创建network文件夹,用于存放接口请求
- 创建common文件夹,用于存放工具类
2.在assets-css文件夹中,全局样式引入 - 引入normailize.css
- 在assets-css文件夹中创建base.css,并引入normailze.css
@import './normalize.css'
:root{
--color-text:#8988888;//字体颜色
--color-high-text:#;//高亮字体颜色
--color-background:#ffffff;//背景颜色
--font-size:14px
--line-height:1.5
}
*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}
a{text-decoretion:none;color:var(--color-text)}
body{
font-family:;
user-select:none;//禁止用户鼠标选中文字图片
color:var(--color-text);
background:var(--color-background);
width:100w;
}
- 在app.vue中引入base.css
3.设置别名和代码编辑格式
- 在根目录下创建vue.config.js用于设置别名
- 在根目录下创建.editorconfig用于规定代码编辑格式
vue.config.js中
module.exports = {
configureWebpack:{
resolve:{
alias:{
'assets':'@/assets',
'components':'@/components',
'views':'@/views',
'network':'@/network',
'common':'@/common'
}
}
}
}
.editorconfig中(官网可搜)
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
# 4 space indentation
[*.py]
indent_style = space
indent_size = 4
# Tab indentation (no size specified)
[*.js]
indent_style = tab
# Indentation override for all JS under lib directory
[lib/**.js]
indent_style = space
indent_size = 2
# Matches the exact files either package.json or .travis.yml
[{package.json,.travis.yml}]
indent_style = space
indent_size = 2