这周主要记录在项目的第一个Sprint周期内遇到的一些问题以及解决的方法。主要包括如下问题:javascript
咱们小组如今的项目是一个订会议室的网页,项目基于vue开发,用vue-cli3搭建,用vuex进行数据的管理。由于我是小白,请你们主要看思想不要在乎代码细节(我知道强迫症看着代码会想改的)。若是有更好的解决方法欢迎大佬们在评论区进行指导,感激涕零!!!css
// svg sprite loader
config.module
.rule('svg')
.exclude.add(resolve('./src/assets/icons'))
.end()
config.module
.rule('svg-icons')
.test(/\.svg$/)
.include.add(resolve('./src/assets/icons'))
.end()
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
.end()
复制代码
<template>
<svg class="icon" :class="className">
<use :xlink:href="href"/>
</svg>
</template>
<script>
export default {
name: 'AppIcon',
props: {
name: {
type: String,
required: true
}
},
computed: {
className () {
return `icon-${this.name}`
},
href () {
return `#${this.name}`
}
}
}
</script>
复制代码
module.exports = {
root: true,
env: {
browser: true,
node: true,
es6: true
},
extends: [
'plugin:vue/essential',
'@vue/standard'
],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
// Indent 2 spaces
indent: ['error', 2],
// Forced use of single quotation marks
quotes: ['error', 'single'],
// Force not to use semicolon ending
semi: ['error', 'never'],
'vue/max-attributes-per-line': ['error', {
'singleline': 5,
'multiline': {
'max': 1,
'allowFirstLine': false
}
}],
'vue/html-self-closing': ['error', {
'html': {
'void': 'never',
'normal': 'never',
'component': 'always'
},
'svg': 'always',
'math': 'always'
}]
},
parserOptions: {
parser: 'babel-eslint',
ecmaVersion: 6 // support ES6 syntax
}
}
复制代码
const StyleLintPlugin = require('stylelint-webpack-plugin')
module.exports = {
configureWebpack: config => {
config.plugins.push(
new StyleLintPlugin({
files: [
'src/sass/**/*.scss'
],
fix: true
})
)
}
}
复制代码
{
"extends": [
"stylelint-config-standard",
"stylelint-config-recommended-scss"
],
"plugins": [
"stylelint-order"
],
"rules": {
"color-no-invalid-hex": true,
"block-no-empty": null,
"number-leading-zero": "never",
"at-rule-no-unknown": null,
"no-descending-specificity",
"font-family-no-missing-generic-family-keyword":null,
"order/properties-order": [
//详细配置见bootstrap源码
]
}
}
复制代码
能够用来放弹框的触发器,这样弹框全部的逻辑均可以写在弹框组件里面。html
<div>
<div @click="showPanel">
<slot name="triger"></slot> //用来放触发器的具名插槽
</div>
<div class="pop-up" v-show="isPanelShow" @click="hidePanel">
<div class="pop-up__main" @click.stop>
<slot>content</slot>
<div class="pop-up__main-left-btn" @click="hidePanel">{{cancel}}</div>
<div class="pop-up__main-right-btn" :class="{ 'pop-up__main-checked': isChecked }" @click="clickConfirm" >{{confirm}}</div>
</div>
</div>
</div>
复制代码
由于表单上不少个样式相同的input框(一部分是输入框,一部分点击后是各类不一样弹框),不想让代码看着不少就想直接把这些框作一次循环,可是这些input框触发的弹框又不同,因此想在input框上绑定一个事件用来触发对应的弹框(咱们的弹框逻辑都封装在弹框组件里面了,因此须要从父组件触发子组件的)vue
<popup-meeting-type ref="meeting-type"/> //在弹框上增长ref
this.$refs['meeting-type'].trigger() //trigger是子组件的方法
复制代码
不要在计算属性内直接修改data里面的数据,eslint会报 no-side-effects-in-computed-properties 错误,若是非要改能够写在一个函数里,而后在计算属性里调用该函数。java
若是想要监测到对象的改变,那么向对象写入/修改数据时必定要用Vue.set。缘由以下: node
简单解释就是,父组件在监听子组件的事件时也能够向下传递参数。webpack
<app-check-group :list="list" @change="handleChange($event, index)"/>
复制代码