巧妙使用!~

66 阅读1分钟

这里巧妙使用!~在if判断中

if(!~state.nodeID.indexOf('ai_id')){
					// 使用 rect css 选择器替代预定义的 body 选择器
					demo.attrs.rect = {     
															fill: '#f6f2f8',
															stroke: '#03a9f4',
														}
					text = inputNode.semanticNodeName;
					textID = inputNode.id;
					// width = text.length * 14 + 30;
					width = 5 * 14 + 30;
				}

这里对于!~undefined !~null都可以变成-1,~1就是-2数值加一然后取反