如何用URL的值命名对象?
let url = 'https://example.com/'
const obj = new constr(img) //i want to name this object (obj) with the ulr's string
class constr(img){
this.img = img;
}
}
如果我理解正确的话,这应该行得通
let obj = {
url: 'https://example.com/'
};
或者是速记,因为您已经定义了变量url
,
let obj = {
url
};