首页 > 解决方案 > 变量的值未正确作为参数传递给方法

问题描述

我正在声明一个变量“account”(分配了 accounts[0] 的值),我试图将其用作调用“this.login”方法的参数(“this.account”)。变量的值未正确传递。但是,如果我使用“accounts”变量作为参数传递,它就可以工作。

 data () {
   return {
    account: null
   }
 }

 this.web3.eth.getAccounts().then((accounts) => {
    this.account = accounts[0]
    if ((!sessionStorage) || (session === '')) {
      this.login(this.account)
    }
 })

我不太明白为什么我不能成功使用“this.account”变量作为调用this.login方法的参数。

标签: javascriptnode.jsvue.js

解决方案


推荐阅读