首页 > 解决方案 > 对象值到数组,然后替换,而不是函数?

问题描述

所以我正在使用 Vue.js,这不是我知道的问题,这只是我做错了,我这样做是有原因的,但我一直收到一个错误,比如它不是数组.

代码:

methods: {
  async register() {
    this.errors = '';
    this.success = '';
    await RegisterService.insertUser(this.email, this.username, this.password, this.passwordTwo)
    .then(data =>  {
      if (data.data) {
        let v = Object.values(data.data);
        console.log(v);
        v = v.replace(/["[]]/g, '');
        this.errors = v;
      } else {
        this.success = `Registration Successful!`;
      }
    });
 }
}

所以我得到的v.replace不是一个函数,我确信这有一个简单的原因,我只是想弄清楚。

标签: javascript

解决方案


推荐阅读