Code Specification
File Naming
For example, use an underscore unified segmentation ** goods_library.vue **
Code format constraints
- vscode install plug EditorConfig
- vscode eslint plug installation, configuration items and settings added
- Editor appears eslint error must be resolved
vscode add configuration
"eslint.validate": [
"javascript",
"javascriptreact",
"vue"
]
css specifications
Unified use scss precompiler
Naming conventions
Use underlined are named, e.g. .main-container
Attribute Order
.main {
position: absolute; // 定位属性放在最前面
top: 0;
left: 0;
display: flex; // 盒子模型放在其次
margin: 10px;
width: 100px;
background: #ee5b5b; // 其他属性放最后
color: #fff;
}
Preparation of specifications
Nesting on the line selector must be a space
.main {
position: absolute;
top: 0;
left: 0;
.wrapper { // 嵌套选择器上一行必须空格
}
}
vue development specifications
- data in the data model as little as possible, the attribute need not be prohibited in response to data written in the page
- Form-related data, when defining the model, in a unified form in
`` `JS
VUE sequentially arranged properties
mixins: [],
data() {},
inject: [],
provide: {},
props: {},
computed: {}
watch: {}
directives: {}
created() {},
mounted() {},
//... 生命周期函数
filters: {}
methods: {}
components: {}
Project directory specification
- Do not place the business under private components in src / components directory, private business components should be established components stored in the directory business-related folders
- assets / js js module placed public, private js js directory for the module should be established under the business-related folders
- assets / style to place public style files, documents to be written in the style file vue prohibited pulled out, when writing a page, you can split the editor to write dom and style, respectively.
- src / config src / directives src / mixins src / utils only storage module and system level function