意外令牌,预期,(8:21)

Unexpected token, expected , (8:21)

所以我正在使用这段代码进行区块链挖掘class

const Block = require('./Block');
class Blockchain{
    constructor(){
        this.chain = [Blockchain.genesis()];
    }
    addBlock({data}){
        const newBlock = Block.mineBlock([
            lastBlock: this.chain[this.chain.length-1],
            data
        ]);
        this.chain.push();
    }
}
module.exports = Blockchain;

而且我不断收到此错误 Unexpected token, expected , (8:21),对于这一行:

lastBlock: this.chain[this.chain.length-1],

任何帮助将不胜感激!

尝试使用这个

Block.mineBlock({
lastBlock: this.chain[this.chain.length-1],
data
})

在我看来和你一样 key:value 对格式不正确.. 大概取

中的代码
lastBlock: this.chain[this.chain.length-1],

上面这行作为 Key 并且期望来自数据的值