我有一个小游戏,有新游戏按钮.按下" 新游戏"按钮时,有许多变量需要重置.是否有任何方法可以轻松地重新加载整个应用程序或任何替代刷新场景,阶段或变量?我只想将应用程序带到它首次加载时的初始阶段.
我在互联网上浏览了不同的主题,并在这里阅读了很多问题和答案,但我没有简单的方法来实现它.大多数答案建议重用整个代码或将整个代码放在类中并重新加载它.
问题回顾:
Angular 5应用程序工作正常但我在使用生产构建它时遇到以下错误.它也很好,ng build但不是ng build --prod.
"email"类型的参数不能分配给'string []'类型的参数.
行上的代码:
<mat-form-field>
<input matInput placeholder="Email" formControlName="email" required>
<mat-error *ngIf="form.hasError('email', 'email') && !form.hasError('required', 'email')">
Please enter a valid email address
</mat-error>
<mat-error *ngIf="form.hasError('required', 'email')">
Email is <strong>required</strong>
</mat-error>
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)
形式:
private createForm() {
this.form = new FormGroup({
email: new FormControl('', [Validators.required, Validators.email]),
password: new FormControl('', Validators.required)
});
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试实现UrlTree在防护失败时重定向用户。
this.authService.isAuthenticated()返回可观察的。
以下不起作用,但它可以控制台false。
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean | UrlTree {
this.authService.isAuthenticated().subscribe(isAuthenticated => {
if (isAuthenticated) {
return true;
} else {
console.log(isAuthenticated);
return this.router.createUrlTree(['auth/sign-in']);
}
});
return false;
}
Run Code Online (Sandbox Code Playgroud)
但如果我删除订阅,则以下内容有效:
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean | UrlTree {
return this.router.createUrlTree(['auth/sign-in']);
}
Run Code Online (Sandbox Code Playgroud) 使用 html2canvas 和 JsPDF 将 HTML 转换为 pdf,并使用下面的代码生成代码,此代码会将 div 的完整 HTML 转换为单个图像,并将在 pdf 中显示为单个页面。
import * as jsPDF from 'jspdf';
import html2canvas from 'html2canvas';
htmltoPDF()
{
// parentdiv is the html element which has to be converted to PDF
html2canvas(document.querySelector("#parentdiv")).then(canvas => {
var pdf = new jsPDF('p', 'pt', [canvas.width, canvas.height]);
var imgData = canvas.toDataURL("image/jpeg", 1.0);
pdf.addImage(imgData,0,0,canvas.width, canvas.height);
pdf.save('converteddoc.pdf');
});
}
Run Code Online (Sandbox Code Playgroud)
为了分割代码,我使用下面的代码将页面分割成多个页面,但没有正确分割空间,因为我的 pdf 附加了小图像。
var imgWidth = 210;
var pageHeight = 295;
var imgHeight = canvas.height * imgWidth / canvas.width;
var …Run Code Online (Sandbox Code Playgroud) 我的代码将用户输入的字符与具有字符的 ArrayList 进行匹配,并显示结果。我使用循环和 IF 语句来打印匹配字符和不匹配字符的不同结果。我使用 Array.Contains() 方法将用户输入与 ArrayList 元素进行比较。我试图在匹配时打印元素在 ArrayList 中的位置。
例如:ArrayList 有:[a, b, c, d] 和位置(a 为 0,b 为 1,c 为 2,d 为 3)。如何以编程方式打印匹配元素的位置?
这是我的代码:
ArrayList<Character> charsList = new ArrayList<Character>();
for (int i = 0; i < wordsList[0].length(); i++) {
charsList.add(wordsList[0].charAt(i));
}
for (int i = 0; i < wordsList[0].length(); i++) {
inputValue = input.next().charAt(0);
if (charsList.contains(inputValue)) {
System.out.println("Matched!");
}
else {
System.out.println("Not Matched!");
}
}
Run Code Online (Sandbox Code Playgroud) 如何将徽标与我的导航栏对齐?
我的 HTML 代码是:
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="icon" type="image/png" href="SENCOR_Logo.ico">
<title>SENCOR</title>
</head>
<body>
<div class="bg-div">
<img class="logo-img" src="SENCOR_Logo.jpg" ALT="align box" ALIGN=CENTER>
<nav>
<ul>
<li><a href="#">Monitoring</a></li>
<li><a href="#">Process</a></li>
<li><a href="#">Post and Create Email/Excel</a></li>
<li><a href="#">Reports</a></li>
<li><a href="#">Tools</a></li>
<li><a href="#">Sales</a></li>
</ul>
</nav>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是我的 style.css 代码:
body{
margin: 0;
padding: 0;
font-size: 15px;
}
/* Navigation */
nav{
margin: 0;
overflow:hidden;
text-align: center;
}
nav ul{
margin: 0;
padding: 0;
}
nav ul li{
display: inline-block; …Run Code Online (Sandbox Code Playgroud) 我最近直接从网站上安装了MySQL(mysql-5.7.9-osx10.10-x86_64.dmg),并且在尝试更改给定密码时遇到了很多困难.返回的错误是:
[警告]在命令行界面上使用密码可能不安全.mysqladmin:在'localhost'连接到服务器失败错误:无法通过套接字连接到本地MySQL服务器'/tmp/mysql.sock(2)'检查mysqld是否正在运行并且套接字:'/ tmp/mysql.sock '存在!
从这里我试图找到"usr"文件夹(显示隐藏文件),甚至是在我的计算机上任何地方与MySQL非常相似的任何东西,除了安装.dmg文件之外什么都没有.
我知道MySQL已经安装,因为它现在可以在"系统偏好设置"窗格中启动和停止,但显然我的命令都没有工作,无论我做什么,我都会不断收到此错误:
mysql: command not found
Run Code Online (Sandbox Code Playgroud)
有人能给我一些关于我失踪的线索吗?我变得非常绝望,无法弄清楚我做错了什么.我正在经营El Capitan.
我想使用async/waitReact componentDidMount()方法,但我得到 等待是一个保留字错误.我也尝试将语句包装在Immediate Invoked Function中,但它没有帮助.
async componentDidMount() {
this.geoLocation.getAddress().then(location => {
if (location.address != null && location.error != "undefined") {
let fifteenMins = [];
await this.getFifteenMinsData(y, x).then(
data => {
fifteenMins = data["forecasts"];
}
);
console.log(fifteenMins);
}
});
}
Run Code Online (Sandbox Code Playgroud)
如果我删除了await关键字,那么我进入nullconsole.log,但是如果我在之前做控制台日志,fifteenMins = data["forecasts"];那么我得到数据.
相关问题: Await是异步函数中的保留字错误
我想将背景格式为Excel的数据导出到标题行。
我已使用Angular2Csv导出文件,但无法向标题添加背景色。
let options = {
fieldSeparator: ',',
quoteStrings: '"',
decimalseparator: '.',
showLabels: true,
title: 'Doctors Report',
showTitle: true,
headers: ['Fullname','Email','Phone No','],
};
new Angular2Csv(localArray, 'Title', options);
Run Code Online (Sandbox Code Playgroud)
我想以excel / csv格式导出带有标题背景的数组。
XML 文档已嵌入 DTD 声明并且失败。
这里是DTD:
<!DOCTYPE movieList [
<!ELEMENT movieList (movie+)>
<!ELEMENT movie (title+, rating+, runTime+, genreList*, dateReleased+,
country+, review+, description+, director+)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT rating (#PCDATA)>
<!ELEMENT runTime (#PCDATA)>
<!ELEMENT genreList (genre+)>
<!ELEMENT genre (#PCDATA)>
<!ELEMENT dateReleased (#PCDATA)>
<!ELEMENT country (#PCDATA)>
<!ELEMENT review (#PCDATA)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT director (#PCDATA)>
]>
Run Code Online (Sandbox Code Playgroud)
这是 XML 元素:
<movieList>
<movie>
<title>Jaws</title>
<rating>PG</rating>
<runTime>124 minutes</runTime>
<genreList>
<genre>Adventure</genre>
<genre>Thriller</genre>
</genreList>
<dateReleased>20 June 1975</dateReleased>
<country>USA</country>
<review>8</review>
<description>When a gigantic great white shark begins to menace …Run Code Online (Sandbox Code Playgroud)