The written form of variables in the js object

var data = { this.tableData,ths.observerValue } // 

const { tableData,observerValue } = this
var data = { tableData,observerValue } // ok

is there any other way besides structure?


the error is reported because the concise representation of attributes is used by default

const baz = {foo};
// 
const baz = {foo: foo};

var data = {
            tableData: this.tableData,
            observerValue: this.observerValue
}
// 

ES6 allows you to write variables directly in an object. At this point, the attribute name is the variable name and the attribute value is the value of the variable.

Menu