Vue the methods to obtain the data () id, a data type is a string, this id corresponds to the data () a data, could you tell me how to locate the data I () in the data and change it? Because id is changing;
Data () {
V1:1001,
V2:1002,
V3:1003
}
Methods: {
Func (id) {
//id for v1, v2 and v3, how to get, don't want to keep the if else, because the data in the data is very much also, v1, etc can't exist in an array of my idea is to iterate through the data (), but I don't know traversal data written ()
}
}
CodePudding user response:
Need not be clear,Is to be like this?
Data () {
Return {
V1:1001,
V2:1002,
V3:1003,
1001: 'needs data'
}
}
Methods: {
Func (id) {
//id='v1'
The console. The log (this [this [id]])
}
}
CodePudding user response:
The data in an object or an array, and then loopIf the for -
CodePudding user response:
There are other methods? I want to know if there is any vue by string value corresponding to find the data () method in valueCodePudding user response:
The