Facebook提供了构建反应应用程序的create-react-app 命令.当我们运行时npm run build,我们看到/build文件夹中的输出.
npm run build
将生产应用程序构建到构建文件夹.它正确地将React捆绑在生产模式中并优化构建以获得最佳性能.
构建被缩小,文件名包含哈希.您的应用已准备好部署!
我们如何使用自定义文件夹而不是/build输出?谢谢.
我正在使用$anchorScroll滚动到页面顶部html元素具有ID #brand.
<body>
<header id="brand">
<!--Content-->
</header>
</body>
Run Code Online (Sandbox Code Playgroud)
AngularJS代码:
$location.hash("brand");
$anchorScroll();
Run Code Online (Sandbox Code Playgroud)
但是,在$anchorScroll运行之后,页面URL变为http://localhost:8080/##brand,这意味着##brand附加到原始URL.使用时如何保留原始网址$anchorScroll?提前致谢!
我在网上找不到同样的问题.IE 11给出错误"对象不支持属性或方法fill".
var arr = new Array(5);
arr.fill(false);
Run Code Online (Sandbox Code Playgroud)
有没有方便的方法来填充数组而不是使用for循环?谢谢.
我正在编写一个函数来检查输入字符串是有效的JSON还是有效的XML,或者两者都没有.我在这里发了一个帖子.但显然帖子中的答案是不正确的,因为它们只检查字符串是否以<或开头{,这不能保证字符串是有效的 JSON或有效的 XML.
我自己有一个解决方案,那就是:
public static String getMsgType(String message) {
try {
new ObjectMapper().readTree(message);
log.info("Message is valid JSON.");
return "JSON";
} catch (IOException e) {
log.info("Message is not valid JSON.");
}
try {
DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(message)));
log.info("Message is valid XML.");
return "XML";
} catch (Exception e) {
log.info("Message is not valid XML.");
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
我想知道是否有更好或更短的解决方案?谢谢.
当我启动 Spring 应用程序时,我可以在控制台中看到启动时间(我使用的是 IntelliJ IDEA)。
例如,下面的日志显示应用程序的启动时间为 13.427 秒。
2016-12-29 13:58:05.491 : Starting Application on 8DSXD72 with PID 14120
2016-12-29 13:58:05.518 : Running with Spring Boot v1.4.1.RELEASE, Spring v4.3.3.RELEASE
2016-12-29 13:58:05.519 : The following profiles are active: LOCAL
2016-12-29 13:58:15.537 : JMX is disabled
....
2016-12-29 13:58:17.392 : Started Application in 13.427 seconds (JVM running for 14.71)
Run Code Online (Sandbox Code Playgroud)
有没有办法在代码中获取这个启动时间?我想在 Spring 端点中打印出应用程序启动时间/info。
我在IntelliJ IDEA中使用ES6。下面是一段代码。
import controller from './tpmInfo.ctrl.js'
import template from './tpmInfo.tpl.html' //default export is not declared in imported module
export default angular.module('tmpApp', [])
.component('tpmInfo', {
template: template,
controller: controller,
bindings: {
ags: '='
}
})
.name;
Run Code Online (Sandbox Code Playgroud)
该templatehtml是普通的html,但是IntelliJ IDEA引发警告“在导入的模块中未声明默认导出”。有什么办法可以使该警告消失?谢谢。
以下两种转换Object为 的方法有什么区别Map?假设两种方法都可以将 an 转换Object为 a ,哪种方法更好Map?
投掷:
Object o = some object;
Map<String, Object> map = (Map<String, Object>) o;
Run Code Online (Sandbox Code Playgroud)
对象映射器:
Object o = some object;
Map<String, Object> map = new ObjectMapper().readValue((String) o, new TypeReference<Map<String, Object>>() {});
Run Code Online (Sandbox Code Playgroud) 我们知道有四种类型的指令:
HTML element (E)
an attribute on an element (A)
a CSS class (C)
comment (M)
Run Code Online (Sandbox Code Playgroud)
我们可以restrict: 'EACM'在指令中使用.但是,当我们需要指令时,有人能给出一个实际的例子element, attribute, css class and comment吗?谢谢.
我安装了nodejs,并尝试在我的Windows机器上使用npm.我从nodejs网站下载了所有文件.我尝试安装最新4.4.2版本或5.10.1版本,但是Cannot find module 'readable-stream'当我尝试使用命令运行时,我总是遇到错误npm.
C:\Users\Ealon>node -v
v5.10.1
C:\Users\Ealon>npm -v
module.js:341
throw err;
^
Error: Cannot find module 'readable-stream'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (C:\Users\Ealon\AppData\Roaming\npm\node_modules\npm\node
modules\npmlog\node_modules\are-we-there-yet\index.js:2:14)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
Run Code Online (Sandbox Code Playgroud)
我试图一次又一次地重新安装它,仍然无法解决这个问题.而另一个类似问题的答案没有帮助,因为当我尝试使用任何命令npm时,我总是遇到错误.任何帮助表示赞赏.谢谢!
下面是apply和call功能:
function.apply(context, [args])
function.call(context, arg1, arg2, ...)
我们知道和之间的区别:applycall
不同之处在于 apply 允许您使用数组形式的参数来调用函数;调用需要显式列出参数。
现在我们有了扩展语法,我们可以轻松地使用它call来执行以下apply操作:
function.call(context, ...[args])
那么对于展开语法,我们什么时候使用applyover呢call?我很好奇apply功能是否可以退休。