//程序运行完成时一定要有输出语句,本工具才能正确展示运行结果。 
console.log("Hello JSRUN!   \n\n         - from NodeJS .");
//程序运行完成时一定要有输出语句,本工具才能正确展示运行结果。 
var obj = {}
module.exports = {
    obj,
    add: (a) => {
        obj = { ...obj, ...a }
        console.log('calculator: obj:  ', obj)
    },
    getObj: () => {
        console.log('calculator obj:  ', obj)
    },
}
zwkkkk1(null) - 2019-07-17 0 人
es6 demo
var function = print(s){
    console.log(s);
}
print(1)
bjbsw(∝ 吥屑゛) - 2019-07-15 0 人
20190715
console.log("Hello JSRUN!   \n\n         - from NodeJS .");

console.log("Hello JSRUN!   \n\n         - from NodeJS .");

const datatree = [
    {
        key: 1,
        title: '1',
        children: [
            {
                key: 2,
                title: '1-1',
            },
            {
                key: 3,
                title: '1-2',
            },
            {
                key: 4,
                title: '1-3',
            }
        ]
    },
    {
        key: 5,
        title: '2',
        children: [
            {
                key: 6,
                title: '2-1',
            }
        ]
    },
    {
        key: 7,
        title: '3',
    }
]


const renderTreeNode = (datatree) =>{
    datatree.map((item,index)=>{

        if(datatree.children){
            // 执行默认方法
        }else{
            // 调用自己,讲第二层的子节点传入 
            renderTreeNode(datatree.children)
        }
    })
}
superprops(Luvsta) - 2019-07-11 0 人
树节点的递归遍历
console.log("Hello JSRUN!   \n\n         - from NodeJS .");

const datatree = [
    {
        key: 1,
        title: '1',
        children: [
            {
                key: 2,
                title: '1-1',
            },
            {
                key: 3,
                title: '1-2',
            },
            {
                key: 4,
                title: '1-3',
            }
        ]
    },
    {
        key: 5,
        title: '2',
        children: [
            {
                key: 6,
                title: '2-1',
            }
        ]
    },
    {
        key: 7,
        title: '3',
    }
]


const renderTreeNode = (datatree) => {

    datatree.map((item, index) => {

        if (datatree.children) {
            // 调用自己,将第二层的子节点传入 
            renderTreeNode(datatree.children)
        } else {
            // 执行默认方法
            console.log(data.title)
        }
    })
    
}
superprops(Luvsta) - 2019-07-11 0 人
树节点的递归遍历
let resData = {
    rows: {
        201906: [['A', 10], ['B', 15], ['C', 20]],
        201905: [['A', 15], ['B', 20], ['C', 10]],
        201904: [['A', 20], ['B', 10], ['C', 15]]
    }
}
let rows = resData.rows
//添加索引
function addIndex(date) {
    return rows[date].map((item, index) => {
        let newArr = [...item]
        newArr.push(index)
        return newArr
    })
}
let addIndexArr = addIndex('201905')
//获取排序后索引
function getSortIndex() {
    let sortArr = addIndexArr.sort(function (a, b) {
        return b[1] - a[1]
    })
    let sortIndex = sortArr.map(item => {
        return item[2]
    })
    return sortIndex
}
let sortIndexArr = getSortIndex()
//获取新rows
function getNewRows() {
    let newRows = {}
    let rowsKeys = Object.keys(rows)
    //只要每项数组的前2个
    let newSortIndexArr = sortIndexArr.splice(0, 2)
    rowsKeys.forEach(key => {
        newRows[key] = newSortIndexArr.map(sortIndex => {
            return rows[key][sortIndex]
        })
    })
    return newRows
}
let newRows = getNewRows()
console.log(newRows)
listener(前端大神) - 2019-07-11 0 人
响应数据处理测试
没有了
1/35 下一页