我已经有了父页面的“ breedKey”值和返回的“ thedate”值,如何将这两个值放入axios.get URL中,我想用这种方式在URL中替换它们
“https://www.mustavi.com/TimeSeries/?param1={{breedkey}}&param2 = {{thedate}}”]
props: ["breedKey", "time"],
data() {
return {
thedate: this.time
};
},
async created() {
let myparam1 = breedKey;
let myparam2 = thedate;
try {
this.promise = axios.get(
"https://www.mustavi.com/TimeSeries/?param1=nctzenselcaday¶m2=2020-04-09"
);
const res = await this.promise;
您可以为此使用template strings
this.promise = axios.get(
`https://www.mustavi.com/TimeSeries/?param1=${myparam1}¶m2=${myparam2}`
);