371 1 分钟

按照一个可指定的深度递归遍历数组: let nestedArray = [1, 2, [3, 4, [5, 6]]];let flatArray = nestedArray.flat();console.log(flatArray);// 输出: [1, 2, 3, 4, [5, 6]] // 指定深度为 2let deeplyNestedArray = [1, 2, [3, 4, [5, 6]]];let deeplyFlatArray = deeplyNestedArray.flat(2);console.log(deeplyFlatArray);// 输出: [1, 2, 3, 4,...
2.2k 2 分钟

# js 基础写法

// 增加
addItem: function () {
var n = this.signForm.signFormList ? this.signForm.signFormList.length + 1 : 1;
	this.signForm.signFormList.push({
	  title: '标题' + n,
	  require: false
	});
},
// 删除
removeItem: function (item) {
	const index = this.signForm.signFormList.indexOf(item);
	this.signForm.signFormList.splice(index, 1);
},
// 置顶
moveTop: function (item) {
	const index = this.signForm.signFormList.indexOf(item);
	if(index != 0){
	  this.signForm.signFormList.splice(index,1);
	  this.signForm.signFormList.splice(0,0,item);
	}
},
// 上移
moveUp: function (item) {
	const index = this.signForm.signFormList.indexOf(item);
	if(index != 0){
		this.signForm.signFormList.splice(index,1);
		this.signForm.signFormList.splice(index-1,0,item);
	}
},
// 下移
moveDown: function (item) {
	const index = this.signForm.signFormList.indexOf(item);
	const max = this.signForm.signFormList.length ;
	if(index != max){
	  this.signForm.signFormList.splice(index,1);
	  this.signForm.signFormList.splice(index+1,0,item);
	}
},

1.2k 1 分钟

# 1.push () 方法

let arr = [23,21,16,23,92]
let res = arr.push('ll') //push 后面增加一个元素
console.log(arr) // 会改变原数组
console.log(res) // 新数组的长度

30k 27 分钟

# D3: Data-Driven Documents

D3 (或 D3.js) 是一个 JavaScript 库,用于使用 Web 标准可视化数据。 D3 帮助您使用 SVG,Canvas 和 HTML 使数据栩栩如生。 D3 将强大的可视化和交互技术与数据驱动的 DOM 操作方法相结合,为您提供现代浏览器的全部功能,并为您的数据设计正确的可视界面提供了自由。

# 官方资源

  • API Reference
  • Release Notes
  • Gallery
  • Examples
  • Wiki

467 1 分钟

# 1. 谷歌浏览器

添加自定义 class

<el-checkbox-group v-model="checkList">
             <el-checkbox class="checkbox"></el-checkbox>
</el-checkbox-group>
.checkbox{
    zoom: 200%;
}

如果发现有浏览器没有作用那就用下面的办法

245 1 分钟

必填项不带星号 form 标签中有 :rules = “rules” 表单项中有 prop 校验规则:{validator: validateCreditCode, trigger: ‘blur’} 把 required: true 去掉即可 拓展:(样式覆盖) /deep/ .el-form-item.is-required:not(.is-no-asterisk)>.el-form-item__label:before &#123; content: ' '; width: 0px; margin-right: 0px;&#125;