我将Angular CLI更新@angular/cli@7.0.2为Mac OS上的最新版本。发出命令时ng new testng7,出现此错误:
Schematic input does not validate against the Schema: {"name":"testng7"}
Errors:
Data path "" should have required property 'version'.
Run Code Online (Sandbox Code Playgroud)
什么也没有创造。任何线索如何解决?
有没有一种方法可以将这种replace方法应用于一般的Unicode文本(这里是阿拉伯语)?在下面的示例中,虽然替换整个单词在英语文本上效果很好,但是它无法检测到,因此替换了阿拉伯单词。我添加了u作为标记以启用unicode解析,但这没有帮助。在下面的阿拉伯语示例中,单词?????? 应该替换,但不能替换???????,但这不会发生。
<!DOCTYPE html>
<html>
<body>
<p>Click to replace...</p>
<button onclick="myFunction()">replace</button>
<p id="demo"></p>
<script>
function myFunction() {
var str = "????? ?????? ???????? ?? ?????? ???????";
var rep = '??????';
var repWith = '?????';
//var str = "the sun and the stars, then the starsz and the day";
//var rep = 'stars';
//var repWith = 'night';
var result = str.replace(new RegExp("\\b"+rep+"\\b", "ug"), repWith);
document.getElementById("demo").innerHTML = result;
}
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
并且,无论您提供什么解决方案,都请使用上面代码中的变量(上面的变量rep),因为要查找的这些替换词是通过函数调用传递的。
更新:要尝试上面的代码,请用上面的代码替换此处 …
在下面的代码快照中app.component.html,我在第 39 到 58 行的表中显示可单击的行。一旦用户单击一行,我就会在suraTable第 63 到 77 行所示的表中显示其他相关行。即,当用户单击时连续调用函数onSelectAya(aya, suraTable)in 。app.component.ts该函数加载必要的行并显示表格。
我所坚持的是这个。假设suraTable最终有 100 行。当前的行为是当然显示第 1、2、3...行。我需要能够显示第 50 行的表格(aya第 91 行参数中携带的信息)。我如何滚动到该位置?我尝试了scrollTop方式,但是当检查设置之前和之后的值时suraTable.scrollTop,该值始终为0(即0像素)。第 100 行显示,当console.log(suraTable)到达时,浏览器中会生成预期的输出,这意味着我一开始就正确地掌握了该元素。
那么,如何从组件内滚动到表中的特定行或列表中的项目(如果更容易的话,我可以将整个结构转换为列表)app.component.ts?谢谢。
我正在尝试在我的 Angular 6 应用程序中实现类似“您是 n 号访客”的功能。我没有使用数据库,所以最好的办法是将数字存储在资产文件夹中的文件中,然后从中读取数字,更新并存储增加的数字。
阅读很容易,如:
this.http.get("/assets/visits").subscribe(vn => {
this.visitNums = +vn + 1;
});
Run Code Online (Sandbox Code Playgroud)
但我在写入文件时遇到问题。我试过:
fs.writeFile("/assets/visits, 'whatever',
err => console.log(err));
Run Code Online (Sandbox Code Playgroud)
但即使使用以下命令,我也会收到“找不到 fs 模块”的消息:
import * as fs from "fs";
Run Code Online (Sandbox Code Playgroud)
而且,还做了:
declare const fs: any;
Run Code Online (Sandbox Code Playgroud)
在该行给出“fs 未定义” fs.writeFile。
那么,有没有办法从 Angular 6 应用程序中写入文件?
angular ×3
angular-cli ×1
angular7 ×1
console ×1
file ×1
gradle ×1
grails ×1
html ×1
javascript ×1
regex ×1
scroll ×1
typescript ×1