扁平化:将多层嵌套的数组转换成只有一层的数组
使用数组的flat方法
根据mdn的解释,flat() 方法会按照一个可指定的深度递归遍历数组,并将所有元素与遍历到的子数组中的元素合并为一个新数组返回
1 | let arr1 = [0, 1, 2, [3, 4]]; |
使用reduce
1 | let arr = [0, 1, 2, [[[3, 4]]]]; |
使用…扩展运算符
1 | let arr = [0, 1, 2, [[[3, 4]]]]; |
缺失模块。
1、请确保node版本大于6.2
2、在博客根目录(注意不是yilia根目录)执行以下命令:
npm i hexo-generator-json-content --save
3、在根目录_config.yml里添加配置:
jsonContent:
meta: false
pages: false
posts:
title: true
date: true
path: true
text: false
raw: false
content: false
slug: false
updated: false
comments: false
link: false
permalink: false
excerpt: false
categories: false
tags: true