0
点赞
收藏
分享

微信扫一扫

VSCode自定义代码片段—— 数组的响应式方法

数组的响应式方法

{
	// arr'fuction
	// 如何自定义用户代码片段:VSCode =》左下角设置 =》用户代码片段 =》 自定义片段名称 =》编辑用户片段 =》ctrl+S 保存
	// 数组的响应式方法:
	"Print to console": {
		"prefix": "arr'fuction",
		"body": [
			"/*arr'fuction 数组的那些方法是响应式的: */",
			"//1,push方法 末尾添加多个",
			"this.names.push(\"push方法是否能做到响应式:true\");",
			"//2,通过索引修改数组中的元素",
			"this.names[0] = \"this.names[0]修改数组中的元素能否做到响应式:false\";",
			"//3,pop() 末尾删除 pop方法是否能做到响应式:true",
			"this.names.pop();",
			"//4,shift() 首位删除 shift方法是否能做到响应式:true",
			"this.names.shift();",
			"//5,unshift() 首位添加多个",
			"this.names.unshift(\"unshift方法是否能做到响应式:true\");",
			"//6,splice作用:删除元素/插入元素/替换元素 splice方法是否能做到响应式:true",
			"this.names.splice(start, delNumber, \"...\");",
			"//                start代表从第几个索引值开始操作,delNumber为要删除的索引值的数量,delNumber后面的所有参数为依次要添加的索引值",
			"//7,sort() 数组有序排列 sort方法是否能做到响应式:true",
			"this.names.sort();",
			"//8,reverse() 数组反转 reverse方法是否能做到响应式:true",
			"this.names.reverse();",
			"//补充: 三种通过索引值修改数组中的元素",
			"this.names[0] = \"wu\"; //...:false",
			"this.names.splice(0, 1, \"wu\");  //...响应式:true",
			"//Vue对象的set方法修改,set(要修改的对象,索引值,修改后的值)",
			"Vue.set(this.names, 0, \"wu\");  //可变参数...n  n是用于存放参数的数组, ...响应式:true     ",
		],
		"description": "数组的响应式方法"
	}
}

@沉木

举报

相关推荐

0 条评论