--

262 阅读1分钟
  1. find,filter,map,forEach,reduce
// reduce用法
let array = [1, 2, 3, 4]
let initialValue = 0
// firstValue 第一次的值,如果有initialValue,则为initialValue,没有initialValue,则为数组[0]的值
// currentValue 当前值,如果有initialValue,则为array[0],没有initialValue,则为array[1]的值
const sumNumber = array.reduce((firstValue, currentValue, index, array) => {
    return firstValue + currentValue
}, initialValue)
console.log('sumNumber', sumNumber) // 10 -> 0+1+2+3+4
  1. import { mapState } from 'vuex' computed: { ...mapState(['xxx', 'xxxx']), ...mapState('permission', ['avatar', 'account']) }
  2. async await --awiat在等primose的then.参考链接1 处理错误
 this.getMydata()

 async getMydata() {
    const data = await this.delayTwo()
    console.log('uuuuuuu=', data) // {age: 18}
 },

delayTwo() {
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            resolve({
                age: 18
             })
        }, 1000)
    })
},
  1. vue-api all

5、test 'componentA':componentA, is 根据组件名,动态切换组件,简单

6、Class

7、Nginx

8、自定义指令钩子函数

// main.js
import Directive from './directive/index'
Vue.use(Directive)

// 文件./directive/index.js
import hasPermi from './permission/hasPermi'
const install = function(Vue) {
  Vue.directive('hasPermi', hasPermi) //v-hasPermi
}
export default install

// 文件./permission/hasPermi.js
export default {
  inserted(el, binding, vnode) {
    const { value } = binding
    el.parentNode && el.parentNode.removeChild(el)
  },
  // ...其他钩子函数
}

9、...mapState

Git全局设置

git config --global user.name "binary"
git config --global user.email "xxx@qq.com"

创建git仓库

mkdir testpppp
cd testpppp
git init 
touch README.md
git add README.md
git commit -m "first commit"
git remote add origin https://gitee.com/binarylhb/testpppp.git
git push -u origin "master"

已有仓库

cd existing_git_repo
git remote add origin https://gitee.com/binarylhb/testpppp.git
git push -u origin "master"