i have quick question here.
I have my object with value:
JavaScript
x
8
1
data() {
2
return {
3
nation: {
4
CZ: require("../../../../../svg/czech-flag.svg"),
5
}
6
};
7
},
8
Then have API object (API is working fine, fyi)
JavaScript
1
4
1
doctor: {
2
region: "CZ"
3
}
4
I wanna do something like this (is not working of course):
JavaScript
1
2
1
<div v-html="nation.doctor.region></div>
2
I had method for this, it worked, but I think it can be easier to do that. Thanks a lot for any help
Advertisement
Answer
You can use something like nations[`${doctor.region}`]
Working code:
JavaScript
1
12
12
1
const data = {
2
nations: {
3
CZ: 'Czech'
4
}
5
}
6
7
const doctor = {
8
region: 'CZ'
9
}
10
11
console.log(data.nations[`${doctor.region}`])
12