我正在尝试使用 CardInfo 类型加载 ScriptableObjects:
CardInfo[] allCardsList;
allCardsList = Resources.LoadAll<CardInfo>("");
但数组最终是空的。尽管资源文件夹存在,并且里面有我需要的文件。可能是什么问题?
我正在注册一个用户。我想添加对电子邮件是否存在的检查。那些。在 Node.js 服务器上,检查电子邮件是否存在,如果存在,用户应该收到消息“拥有此电子邮件的用户已存在!”。我想通过在电子邮件输入字段下插入一个块来做到这一点。怎么做?
这是服务器的响应。我似乎让客户端接受了响应,但我不知道如何传递错误。
app.post('/registration', (req, res) => {
if (!req.body) return res.sendStatus(400);
const fullname = req.body.name.split(' ');
const email = req.body.email,
name = fullname[0],
last_name = fullname[1],
pass = req.body.pass,
repass = req.body.double-pass;
let query = 'SELECT EXISTS(SELECT email FROM users WHERE email =?) AS emailExists';
const connection = sqlconnect();
connection.query(query, [email], (err, result) => {
console.log(result);
if (result[0].emailExists === 1) {
res.send('email уже есть');
} else {
let insert = 'INSERT INTO users (email, name, last_name, password) VALUES (?,?,?,?)';
connection.query(insert, [email, name, last_name, pass]);
}
})
// res.render('auntefication/registration');
});
客户
const formButton = document.getElementById('formButton');
const form = document.getElementById('reg');
formButton.addEventListener('click', function(event) {
event.preventDefault();
const formData = new FormData(form);
const searchParams = new URLSearchParams(formData);
fetch('/registration', {
method: 'POST',
body: searchParams
}).then(response => response.text()).then(data => {
console.log(data); // Выводим ответ от сервера в консоль
}).catch(error => {
console.error('Error:', error);
});
fetch('/registration', {
method: 'GET'
}).then(res => res.text())
.then(message => alert(message));
});
有如下js代码:
let input = document.getElementById('nick');
//создаем элемент, в котором будет содержаться ошибка
let elem = document.createElement('div');
elem.id = 'notify';
elem.style.display = 'none';
document.getElementById('form__item1').appendChild(elem);
function errorNick() {
let errorNickname;
if (!input.validity.valid && input.value != "") {
elem.textContent = 'Можно использовать только латинские символы, цифры, - и _ ! Длина ника от 5 до 16 символов!';
elem.className = 'error';
elem.style.display = 'block';
input.className = 'pod';
errorNickname = true;
}
else {
errorNickname = false;
}
return errorNickname;
}
input.addEventListener('input', function(event){
//Добавление подъема заголовка, если в поле есть текст
if (input.value.length > 0) {
input.className = 'pod';
}
else {
input.className = '';
}
if ( 'block' === elem.style.display ) {
input.className = 'pod';
elem.style.display = 'none';
}
});
还有第二个文件,如果没有错误,我想重定向到另一个页面。
function allGood() {
if (invalidPass() && (errorNick())) {
window.location("http://www.broadsmile.ru");
}
}
现在我的 errorNickname 变量始终设置为 false,即 没有错误。我怎样才能解决这个问题?这是表格本身:
<form method="post" id="form-reg"name="reg">
<H2>Регистрация</H2>
<div id="form__item1" class="form__item">
<div id="row" class="row">
<ion-icon name="person-circle-outline"></ion-icon>
<input id="nick" name="nick" pattern="[A-Za-z0-9\-_]{5,16}" onchange="errorNick()" required>
<label for="">Ник:</label>
</div>
</div>
<div class="form__item">
<div class="row">
<ion-icon name="mail-outline"></ion-icon>
<input id="email" type="email" name="email" required>
<label for="">E-mail:</label>
</div>
<div id="errorEmail" class="error"></div>
</div>
<div class="form__item">
<div class="row">
<ion-icon name="lock-closed-outline"></ion-icon>
<input id="pass" type="password" name="pass" required>
<label for="">Пароль:</label>
</div>
</div>
<div class="form__item">
<div class="row">
<ion-icon name="lock-closed-outline"></ion-icon>
<input id="pass2" type="password" name="pass2" onchange="return invalidPass()" required>
<label for="">Подтвердите пароль:</label>
</div>
<div id="errorPass2" class="error"></div>
</div>
<input type="submit" value="Зарегистрироваться" class="submitBotton" onclick="return allGood()">
</form>
吃
* {
margin: 0;
padding: 0;
}
body {
font-family: Roboto, Arial, sans-serif;
}
.logo {
color: white;
font-size: 2em;
font-weight: 700;
}
header a {
text-decoration: none;
color: white;
}
header {
display: flex;
justify-content: space-between;
background-color: #ff4800;
height: 60px;
align-items: center;
position: fixed;
width: 100%;
padding: 0 0 0 20px;
}
.spisok {
display: flex;
align-items: center;
height: 100%;
margin-right: 20px;
}
.items {
font-size: 1.3em;
display: flex;
justify-content: space-between;
list-style: none;
height: 100%;
}
.spisok ul {
color: white;
display: flex;
align-items: center;
height: 60px;
}
.items li {
line-height: 60px;
padding: 0 20px;
}
.items li:hover {
background-color: #d23a00;
transition: .5s;
color: white;
cursor: pointer;
}
<header>
<div class="logo">
<p><a href="index.html">Broad Smile</a></p>
</div>
<div class="spisok">
<ul class="items">
<li><a href="#">О нас</a></li>
<li><a href="#">Покупка доната</a></li>
<li><a href="#">Серверы</a></li>
<li><a href="#">Правила</a></li>
<li><a href="#">Контакты</a></li>
<li><a href="#">Личный кабинет</a></li>
</ul>
</div>
</header>
我想让选项卡在悬停时变暗一点。此选择应为菜单高度的 100%。这是工作代码,但是当我想在 li 标签上(在 .items li{} 选择器中)将行高设置为百分比时,没有任何反应。但是,如果我以像素为单位指定 - 一切都会发生。这怎么能解决?
你需要做的是:在文本中找到“of”“in”“new”“from”“this”“rail”“spliter”等词,将它们输出到控制台以及它们出现的索引,对于例如,程序的结果应该是这样的:
of -> 16
of -> 60
...
我写了这段代码,但它不起作用:
let m = "The nationalism of Hamilton was undemocratic. The democracy of Jefferson was, in the beginning, provincial. The historic mission of uniting nationalism and democracy was in the course of time given to new leaders from a region beyond the mountains, peopled by men and women from all sections and free from those state traditions which ran back to the early days of colonization. The voice of the democratic nationalism nourished in the West was heard when Clay of Kentucky advocated his American system of protection for industries; when Jackson of Tennessee condemned nullification in a ringing proclamation that has taken its place among the great American state papers; and when Lincoln of Illinois, in a fateful hour, called upon a bewildered people to meet the supreme test whether this was a nation destined to survive or to perish. And it will be remembered that Lincolns party chose for its banner that earlier device--Republican--which Jefferson had made a sign of power. The \"rail splitter\" from Illinois united the nationalism of Hamilton with the democracy of Jefferson, and his appeal was clothed in the simple language of the people, not in the sonorous rhetoric which Webster learned in the schools.";
let tmp = "";
let i, j;
for(i = 0; i < m.length; i++) {
if((m.charAt(i) == "o") || (m.charAt(i) == "i") || (m.charAt(i) == "n") || (m.charAt(i) == "f") || (m.charAt(i) == "t") || (m.charAt(i) == "r") || (m.charAt(i) == "s")) {
index = i; //в нем храним индекс первой буквы в потенциально подходящем слове
for (j = i; m.charAt(j) != " "; j++) {
tmp = tmp + m.charAt(j);
}
if ((tmp == "of") || (tmp == "in") || (tmp == "new") || (tmp == "from") || (tmp == "this") || (tmp == "rail") || (tmp == "spliter")) {
console.log(tmp, "- > ", index);
}
}
tmp = "";
}
请帮我解决这个问题
有一段代码:
System.out.println("ВВЕДИТЕ ДАННЫЕ ОБЪЕКТА!");
Scanner input = new Scanner(System.in);
System.out.println("Скорость: ");
speed = input.nextInt();
System.out.println("Вес: ");
weight = input.nextInt();
System.out.println("Тип: ");
type = input.nextLine();
System.out.println("Цвет: ");
color = input.nextLine();
input.close();
一切都输入正确,但代码总是在输入数字后跳过一行输入,但第二行工作正常。可能是什么问题呢?
我遇到了以下代码的问题:
#include<cmath>
using namespace std;
int main() {
setlocale(LC_ALL, "rus");
double b, x;
cout << "Введите значение b: ";
cin >> b;
double U;
for (x = 2; x <= 4; x += 0.2)
{
if (x < 3)
U = 2.75 * log(abs(b * x)) - sqrt(abs(log(x + b)));
else if (x == 3.)
U = x - 2. * sin(b / x);
else
U = exp(x) + log(x) - (10 * x);
cout << "x = " << x << endl;
cout << "U = " << U << endl << endl;
}
}
代码有效,但循环没有完成最后一次迭代。话虽如此,如果我执行以下构造,则代码可以正常工作:
for (x = 2; x <= 4;)
{
x += 0.2;
}
为什么 for 循环不进行最后一次迭代?