- vue子组件和父组件的执行顺序
加载渲染过程:
父组件beforeCreate ==> 父组件created ==> 父组件beforeMount ==>子组件beforeCreate ==>子组件created ==> 子组件beforeMount ==>子组件Mounted ==>父组件Mounted
更新过程: 父组件beforeUpdate ==>子组件beforeUpdate ==>子组件updated ==>父组件updated
销毁过程:父组件beforeDestroy ==》子组件beforeDestroy ==>子组件destroyed ==>父组件destroyed
- 常见冒泡排序算法 -冒泡排序
function bubbleSort(array) {
for(let i = 0; i < array.length - 1; i++) {
for(let j = 0; j< array.length - i - 1; i++) {
if (array[j] > array[j + 1]) { // 3,2
[array[j], array[j + 1]] = [array[j + 1], array[j]]
}
}
}
return array
}
-选择排序
选择排序是冒泡排序的改进
选择排序并不急于调换位置,而是每轮看哪个数最小,记下最小数的位置minIndex,等该轮扫描完毕,再让最小值和当前指定值对换,这样一来每一轮比较都只需要换一次位置。
function selectSort(array) {
let minIndex;
for (let i = 0; i < array.length - 1; i++) {
minIndex = i; // 假设本轮的第一个值为最小值
for (let j = i + 1; j < array.length; j++) { // 默认第一个已排好
if (array[j] < array[minIndex]) {
minIndex = j
}
}
if (i !== minIndex) { //如果该最小值和原最小值不同,则交换其值
[array[i], array[minIndex]] = [array[minIndex], array[i]];
}
}
return array;
}
- vxe-table 强大的基于vue的表格插件
解决table滑动卡顿
vxe-table 和 vxe-grid 的区别: 功能完全一致
-自定义展开行 分页 合并行,合并列 全屏 配置列 弹框展示详情 全表搜索 展开行+手风琴效果
键盘导航 滚动
- computed传参
利用闭包
// html <div>{{ total(3) }}
// js
computed: {
total() {
return function(n) {
return n * this.num
}
},
}