我正在审查angularjs工厂的代码,以便更好地了解它的工作原理.该代码包含一个if
我不完全理解的声明.
在一个plnkr演示中,作者写道:
if ((+!!config.template) + (+!!config.templateUrl) !== 1) {
throw new Error('Expected modal to have exactly one of either `template` or `templateUrl`');
}
Run Code Online (Sandbox Code Playgroud)
if (!(!config.template ^ !config.templateUrl)) {
throw new Error('Expected modal to have exactly one of either `template` or `templateUrl`');
}
Run Code Online (Sandbox Code Playgroud)
显然,通过错误消息,它正在检查两者中是否存在其中一个.我只是不确定它是如何得出结论的.我无法找到任何关于^
或的信息+!
我的问题是:这个if语句如何工作?(^
或+!
或+!!
特异性)
我试图找到一个解决方案,使文本在水平和垂直居中的textarea中键入.水平工作正常,text-align: center;
但垂直居中更麻烦.似乎解决方案是使用填充,但是当文本高达3行时,文本不再居中.在下面的小提琴中,我放置了一条红线,这是我的文本区域的中心.我需要它作为文本出现的中心.即使它是1,2,3,4或五行高.因此,如果我有4行文本,则红线需要位于第2行和第3行之间.
我想知道是否可能没有与jquery有关的工作?