Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/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 删除ReactiveDict值_Javascript_Meteor - Fatal编程技术网

Javascript 删除ReactiveDict值

Javascript 删除ReactiveDict值,javascript,meteor,Javascript,Meteor,这就是我定义某个ReactiveDict变量的方式: this.templateDictionary = new ReactiveDict(); this.templateDictionary.set( 'type', type ); this.templateDictionary.set( 'size', size ); this.templateDictionary.set( 'bgcolor', bgcolor ); this.templateDictionary.set( 'color

这就是我定义某个ReactiveDict变量的方式:

this.templateDictionary = new ReactiveDict();

this.templateDictionary.set( 'type', type );
this.templateDictionary.set( 'size', size );
this.templateDictionary.set( 'bgcolor', bgcolor );
this.templateDictionary.set( 'color', color );
现在我要删除所有内容:

this.templateDictionary.set( 'type', undefined );
this.templateDictionary.set( 'size', undefined );
this.templateDictionary.set( 'bgcolor', undefined );
this.templateDictionary.set( 'color', undefined );
但是如果我执行console.log,我会看到变量获取字符串
未定义
。所以它并没有真正被移除

顺便问一下:一行可以设置多个值吗?

您需要的是:

this.templateDictionary.delete('type');
虽然打印出来仍会显示未定义的
,但这是正常的

要删除字典中的所有键,请执行以下操作:

this.templateDictionary.clear();

有关
ReactiveDict
中所有函数的列表,.

如何删除此ReactiveDict中保存的所有值?啊,是的!清楚是你想要的。答案再次编辑!删除删除一个键,清除所有键