我试图fractional从一个double整体使用的部分中删除该部分:
(d % 1) == 0 ? d.intValue() : d
Run Code Online (Sandbox Code Playgroud)
并遇到以下我不明白的行为:
public static void main(String[] args) {
Double d = 5D;
System.out.println((d % 1) == 0); // true
System.out.println((d % 1) == 0 ? d.intValue() : "not whole"); // 5
System.out.println((d % 1) == 0 ? d.intValue() : d); // 5.0
}
Run Code Online (Sandbox Code Playgroud)
正如您在第三行所看到的,操作员选择该else值 - 5.0即使(d % 1) == 0满足条件.
这里发生了什么?
使用具有以下配置的split chunks插件:
{
entry: {
entry1: [entry1.js],
entry2: [entry2.js],
entry3: [entry3.js],
...
}
optimization: {
splitChunks: {
chunks: "all"
}
}
}
Run Code Online (Sandbox Code Playgroud)
代码将完美地分为:
vendors-entry1-entry2-entry3.js // common for all
vendors-entry1-entry3.js // vendors only required by both entry1, entry3
entry1-entry2.js // common code of entry1 and entry2
entry1.js // unique entry's code
entry2.js
entry3.js
Run Code Online (Sandbox Code Playgroud)
问题是,我现在如何在我的html中使用每个条目的特定供应商(或者在我的特定情况下使用ejs)?
使用HtmlWebpackPlugin建议只需创建一个index.html来加载上述所有内容,尽管用例很明显:
渲染entry1页面时 - 加载:
vendors-entry1-entry2-entry3.js
vendors-entry1-entry3.js
entry1-entry2.js
entry1.js
Run Code Online (Sandbox Code Playgroud)
渲染entry2页面时 - 加载:
vendors-entry1-entry2-entry3.js
entry1-entry2.js
entry2.js
Run Code Online (Sandbox Code Playgroud)
等等..
是否有一种直接,简单的方法来执行以下操作 -
<div class="my-class" my-custom-directive="{{evaluate expression}}"></div>
Run Code Online (Sandbox Code Playgroud)
除非表达式被评估为真,否则angular 不会添加指令?
编辑:
该指令必须是一个属性,所以请不要ng-if使用with restrict: 'E',
ng-classwith restrict: 'C'或ng-attr- 这些解决方案
不适用于自定义指令.
我找到了这种删除空字符串的漂亮方法 - arr = arr.filter(Boolean).
但它似乎不适用于空白字符串.
var arr = ['Apple', ' ', 'Mango', '', 'Banana', ' ', 'Strawberry'];
arr = arr.filter(Boolean);
// ["Apple", " ", "Mango", "Banana", " ", "Strawberry"]
// should be ["Apple", "Mango", "Banana", "Strawberry"]
Run Code Online (Sandbox Code Playgroud)
有没有一种很好的方法来扩展此方法以删除空格,或者我应该通过首先迭代数组来修剪空白?
我正在尝试使用PagingAndSortingRepository带有find MyEntity where field in fieldValues查询的spring ,如下所示:
@Repository
public interface MyEntity extends PagingAndSortingRepository<MyEntity, String> {
List<MyEntity> findByMyField(Set<String> myField);
}
Run Code Online (Sandbox Code Playgroud)
但没有成功.
我希望上面的函数返回其字段与其中一个字段值匹配的所有实体,但它只返回空结果.
即使它看起来像一个非常直接的能力,我在文档中找不到任何引用.
是/如何实现?
谢谢.
java spring spring-data spring-data-mongodb spring-data-commons
看起来 IntersectionObserver 从不考虑display: contents视口中的元素。
这种行为对于 来说是有道理的display: none,但我发现它对于 来说是违反直觉的display: contents。
拥有一个干净的包装器的用例,仅在视口交集上获取和渲染其内容对我来说似乎是有效的。
例子
function callback(entries, observer) {
entries.forEach(entry => {
if (entry.isIntersecting) {
document.getElementById('content').style.display = 'block';
document.getElementById('loader').style.display = 'none';
}
});
};
const observer = new IntersectionObserver(callback);
const target = document.getElementById('wrapper');
observer.observe(target);Run Code Online (Sandbox Code Playgroud)
#wrapper {
display: contents;
}
#content {
display: none;
}Run Code Online (Sandbox Code Playgroud)
<div id="wrapper">
<div id="loader">Loading...</div>
<div id="content">Shown on viewport intersection</div>
</div>Run Code Online (Sandbox Code Playgroud)
查看Mozilla 文档我可以看到:
这些元素本身不会产生特定的盒子
但我仍然希望IntersectionObserver能够检测到它。
所以猜测这是一个由两部分组成的问题:
display-contents …我在我的应用程序中使用$ mdDialog,但是想将它用作"确认"对话框而不是正常对话框.这意味着,在用户单击确认对话框中的两个按钮之一之前,代码流不应继续.我注意到可以使用$ mdDialog.confirm(),但我不确定如何将它与自定义templateUrl和相应的控制器一起用作对话框的内容.
以下是我所写的,就对话框而言可以正常工作,但在打开对话框后代码流不会停止.它应该停止,直到用户点击"确定"或"取消".
$mdDialog.show({
controller: 'incomingCallDialogController',
templateUrl: 'app/components/others/incomingCallDialog/incomingCallDialog.tpl.html',
locals: {message: message},
parent: angular.element(document.body)
}).then(function (answer) {
console.log("here");
}
Run Code Online (Sandbox Code Playgroud) 我一直试图找出用于查找两个时间范围之间重叠小时数的算法,例如:
应该返回12.
和
应该返回4.
所以请帮助我填补创建以下功能的空白:
public static Long findOverlappingInterval(Long startTime1, Long endTime1,
Long startTime2, Long endTime2){
// Any suggestions?
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
编辑:我知道创建两个二进制数组的解决方案,使用AND和总结结果.含义:
但这对我的特定需求没有帮助,因为我想将算法的思想用于solr查询,所以使用数组和二元运算符对我来说不是一个选择.
我正在尝试调试iframe contentWindow,但每次我尝试contentWindow在chrome 59 上查看对象时dev-tools页面都会崩溃.
将该contentWindow属性悬停在断点上或单击控制台记录的对象时会发生这种情况.
我正在使用ReactJS,所以我创造了一个反应小提琴,虽然我不认为这是相关的.
console.logged对象.有没有办法避免崩溃?
javascript iframe google-chrome google-chrome-devtools reactjs
说我Container通过以下方式连接到redux:
const mapStateToProps = ({ MyReducer }) => ({
myProp: MyReducer.myProp
});
Run Code Online (Sandbox Code Playgroud)
是否可以通过父级强制myProp的值(覆盖redux)?
我试过了:
<Container myProp={"notReduxValue"}/>
Run Code Online (Sandbox Code Playgroud)
但是mapStateToProps会覆盖提供的值.
注意:我无法更改容器,我的问题是它是否只能通过父级完成.
(当然这意味着糟糕的状态设计,但不幸的是它已经到了)
谢谢