Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 代理设置一个值_Javascript - Fatal编程技术网

Javascript 代理设置一个值

Javascript 代理设置一个值,javascript,Javascript,var context={}; 让头; context.head=新代理({}{ 获取(对象、道具){ 如果(!头){ 头={ htmlAttrs:{ 朗:“Fr” } } } 如果(prop=='htmlAttrs'){ 返回`${JSON.stringify(head.htmlAttrs)}` } }, 设置(对象、道具、值、记录){ 返回Reflect.set(…参数); } }) context.head.htmlAttrs={ 关键:对 } console.log(context.he

var context={};
让头;
context.head=新代理({}{
获取(对象、道具){
如果(!头){
头={
htmlAttrs:{
朗:“Fr”
}
}
}
如果(prop=='htmlAttrs'){
返回`${JSON.stringify(head.htmlAttrs)}`
}
},
设置(对象、道具、值、记录){
返回Reflect.set(…参数);
}
})
context.head.htmlAttrs={
关键:对
}

console.log(context.head.htmlAttrs)
在本例中,
get()
返回的
obj
变量包含:

var context={};
让头;
context.head=新代理({}{
获取(对象、道具){
如果(!头){
头={
htmlAttrs:{
//包括属性
…obj.htmlAttrs,
朗:“Fr”
}
}
}
如果(prop=='htmlAttrs'){
返回`${JSON.stringify(head.htmlAttrs)}`
}
const text=head中的prop?head[prop]。text():“”
返回文本(&prop.endsWith('Attrs')?`${text}`:text
},
设置(对象、道具、值、记录){
返回Reflect.set(…参数);
}
})
context.head.htmlAttrs={
关键:对
}

console.log(context.head.htmlAttrs)
你到底想做什么?我是@hackape的,你想做什么?