[Vuejs]-Get value from object with Typescript

0👍

Use typeof – it will return string or object. If it returns object you can then use key syntax, otherwise the value will be the variable you can use directly.

s = 'jeremy'
o = {'s':'gordon'}
a = [s,o]
console.log(typeof(a[0])) // string
console.log(typeof(a[1])) //object

0👍

Solved with cast to any.

const data: any = this.row.data;

  
  ...
  mounted() {
    this.row.columns.forEach(element => {
      if (element.show === this.headerMobile) {
        this.titleLabel = element.label;
        const data: any = this.row.data;
        this.titleLabelValue = data[element.show];
      }
    });
  }
  ...

Thx @JGFMK

Leave a comment