程序设计

专业和发烧友程序员的问答


7
Moment.js中的弃用警告-不是公认的ISO格式
我收到警告,提示提供的值不是公认的ISO格式。我今天用矩函数更改了变量,但仍然无法正常工作。 这是警告错误: 弃用警告:提供的值不是公认的ISO格式。此刻的构建要归结到js Date(),它在所有浏览器和版本中都不可靠。不鼓励使用非ISO日期格式,并将在即将发布的主要版本中将其删除。请参阅http://momentjs.com/guides/#/warnings/js-date/了解更多信息。参数:[0] _isAMomentObject:true,_isUTC:true,_useUTC:true,_l:未定义,_i:2016-9-26 19:30,_f:未定义,_strict:未定义,_locale:[对象Object] var entryDate = new Date(); var currentDate = entryDate.getDate(); function between(x, min, max) { return x.valueOf() >= min.valueOf() && x < max.valueOf(); } $('#custom1').change(function () { if ($('#custom1 :selected').val() == 'AU') { var keyword = ''; var aus1_s = moment.tz('2016-9-26 19:30', 'Australia/Sydney'); var aus2_s …



8
在Kotlin中扩展数据类
数据类似乎可以替代Java中的老式POJO。这些类将允许继承是非常可预期的,但是我看不到扩展数据类的便捷方法。我需要的是这样的: open data class Resource (var id: Long = 0, var location: String = "") data class Book (var isbn: String) : Resource() 上面的代码由于component1()方法冲突而失败。data仅将注释留在一个类中也不起作用。 也许还有另一个习惯来扩展数据类? UPD:我可能仅注释子子类,但data注释仅处理构造函数中声明的属性。也就是说,我必须声明所有父项的属性open并覆盖它们,这很丑陋: open class Resource (open var id: Long = 0, open var location: String = "") data class Book ( override var id: Long = …

5
如何在运行JavaScript文件的package.json文件中添加自定义脚本?
我希望能够script1在将要运行的项目目录中执行命令node script1.js。 script1.js是同一目录中的文件。该命令必须特定于项目目录,这意味着如果我将项目文件夹发送给其他人,他们将能够运行相同的命令。 到目前为止,我尝试添加: "scripts": { "script1": "node script1.js" } 到我的package.json文件,但是当我尝试运行时script1,得到以下输出: zsh: command not found: script1 有谁知道将上述脚本添加到项目文件夹的必要步骤? *注意:该命令不能添加到bash配置文件中(不能是计算机专用命令) 如果您需要任何说明,请告诉我。


10
标签或窗口之间的通讯
我正在寻找一种方法,如何在浏览器中的多个选项卡或窗口之间进行通信(在同一域中,而不是在CORS上)而不会留下痕迹。有几种解决方案: 使用窗口对象 postMessage 饼干 本地存储 第一个可能是最糟糕的解决方案-您需要从当前窗口中打开一个窗口,然后您只有在保持打开状态的情况下才能进行通信。如果您在任何窗口中重新加载页面,则很可能失去了通信。 使用postMessage的第二种方法可能启用了跨域通信,但是遇到了与第一种方法相同的问题。您需要维护一个窗口对象。 第三种方法,使用cookie,将一些数据存储在浏览器中,这实际上看起来像是向同一域中的所有窗口发送消息,但是问题是您永远无法知道所有选项卡之前是否都已读取“消息”打扫干净。您必须实现某种超时才能定期读取Cookie。此外,您受到最大Cookie长度(4KB)的限制。 第四个解决方案,使用localStorage,似乎克服了cookie的限制,甚至可以监听事件。可接受的答案中描述了如何使用它。 编辑2018:可接受的答案仍然有效,但是对于现代浏览器来说,有一个更新的解决方案可以使用BroadcastChannel。请参阅其他答案,以获取一个简单的示例,该示例描述了如何使用BroadcastChannel在选项卡之间轻松地传输消息。

11
在React应用程序中拥有服务
我来自一个有角的世界,在那里我可以将逻辑提取到服务/工厂,并在控制器中使用它们。 我试图了解如何在React应用程序中实现相同的目标。 假设我有一个可以验证用户密码输入(强度)的组件。它的逻辑非常复杂,因此我不想将其编写在自己的组件中。 我应该在哪里写这个逻辑?在商店中,如果我使用助焊剂?还是有更好的选择?

7
将curl POST与bash脚本函数中定义的变量一起使用
当我回声时,我得到了它,当我将其输入到终端时,它将运行 curl -i \ -H "Accept: application/json" \ -H "Content-Type:application/json" \ -X POST --data '{"account":{"email":"akdgdtk@test.com","screenName":"akdgdtk","type":"NIKE","passwordSettings":{"password":"Starwars1","passwordConfirm":"Starwars1"}},"firstName":"Test","lastName":"User","middleName":"ObiWan","locale":"en_US","registrationSiteId":"520","receiveEmail":"false","dateOfBirth":"1984-12-25","mobileNumber":"9175555555","gender":"male","fuelActivationDate":"2010-10-22","postalCode":"10022","country":"US","city":"Beverton","state":"OR","bio":"This is a test user","jpFirstNameKana":"unsure","jpLastNameKana":"ofthis","height":"80","weight":"175","distanceUnit":"MILES","weightUnit":"POUNDS","heightUnit":"FT/INCHES"}' https://xxx:xxxxx@xxxx-www.xxxxx.com/xxxxx/xxxx/xxxx 但是在bash脚本文件中运行时,出现此错误 curl: (6) Could not resolve host: application; nodename nor servname provided, or not known curl: (6) Could not resolve host: is; nodename nor servname provided, or not known curl: …

9
ReactJS:最大更新深度超出错误
我试图在ReactJS中切换组件的状态,但出现错误: 超过最大更新深度。当组件重复调用componentWillUpdate或componentDidUpdate内部的setState时,可能会发生这种情况。React限制了嵌套更新的数量,以防止无限循环。 我在代码中看不到无限循环,有人可以帮忙吗? ReactJS组件代码: import React, { Component } from 'react'; import styled from 'styled-components'; class Item extends React.Component { constructor(props) { super(props); this.toggle= this.toggle.bind(this); this.state = { details: false } } toggle(){ const currentState = this.state.details; this.setState({ details: !currentState }); } render() { return ( <tr className="Item"> <td>{this.props.config.server}</td> <td>{this.props.config.verbose}</td> …

7
ImageMagick安全策略“ PDF”阻止转换
Imagemagick的安全策略似乎不允许我执行从pdf到png的转换。转换其他扩展名似乎有效,只是不能从pdf中转换。自安装它以来,我尚未更改任何imagemagick设置...如果操作系统很重要,则我正在使用Arch Linux。 user@machine $ convert -density 300 -depth 8 -quality 90 input.pdf output.png convert: attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/408. convert: no images defined `output.png' @ error/convert.c/ConvertImageCommand/3288.

10
Maven中的“ pom”包装是什么?
我得到了一个maven项目来编译并部署在tomcat服务器上。今天以前我从未使用过Maven,但是我已经在谷歌上搜索了很多。似乎pom.xml此项目中的顶级文件的打包类型设置为pom。 mvn install部署此应用程序后我应该怎么做?我原本希望能够在war某处或某处找到文件,但是我想我在错误的位置查找或缺少一步。
175 java  tomcat  maven 

23
无法解析styles.xml中的符号“主题”(Android Studio)
从今天开始,Android Studio在styles.xml中找不到AppCompat主题,但是例如代码中的AppCompatActivity确实可以识别。我的Android Studio版本是2.2.2,内部版本#AI-145.3360264 我已经尝试升级到最新的构建工具,编译sdk(25)版本等,但是它没有解决问题。 目前,我已经从sdk管理器安装了以下内容: Android API:19和23 SDK平台工具:25.0.1 SDK工具:25.2.3 构建工具:23.0.2和25.0.1 支持库:40 谷歌仓库:39 和其他一些,则不必在此处列出。 应用程序的build.gradle: apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion '25.0.1' defaultConfig { applicationId "xxx.xxxxxxxx.xxxxxxxxx" //not the real applicationId minSdkVersion 14 targetSdkVersion 19 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled true shrinkResources true …

12
Poco安装在cocoapods版本1.0.0.beta.1中显示错误
我的Podfile正常运行,但是更新到cocoapods版本1.0.0.beta.1之后 pod安装显示以下错误 MacBook-Pro:iOS-TuneIn home$ pod install Fully deintegrating due to major version update Deleted 1 'Copy Pods Resources' build phases. Deleted 1 'Check Pods Manifest.lock' build phases. Deleted 1 'Embed Pods Frameworks' build phases. - libPods.a - Pods.debug.xcconfig - Pods.release.xcconfig Deleted 1 'Copy Pods Resources' build phases. Deleted 1 'Check …
175 ios  cocoapods 

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.