RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-519851

XlAlbertlX's questions

Martin Hope
XlAlbertlX
Asked: 2024-08-16 21:24:42 +0000 UTC

ScriptableObjects 不使用 Resources.LoadAll<T>("") 加载

  • 5

我正在尝试使用 CardInfo 类型加载 ScriptableObjects:

CardInfo[] allCardsList;
allCardsList = Resources.LoadAll<CardInfo>("");

但数组最终是空的。尽管资源文件夹存在,并且里面有我需要的文件。可能是什么问题?

资源文件夹

c#
  • 1 个回答
  • 33 Views
Martin Hope
XlAlbertlX
Asked: 2024-03-29 16:39:23 +0000 UTC

如何发送服务器响应以便在客户端执行js脚本?

  • 4

我正在注册一个用户。我想添加对电子邮件是否存在的检查。那些。在 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));
});
javascript
  • 1 个回答
  • 40 Views
Martin Hope
XlAlbertlX
Asked: 2023-07-01 19:35:16 +0000 UTC

如何验证表单上的昵称?

  • 5

有如下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>
javascript
  • 1 个回答
  • 39 Views
Martin Hope
XlAlbertlX
Asked: 2023-06-13 21:01:50 +0000 UTC

增加菜单中 li 标签的高度

  • 5

吃

* {
  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{} 选择器中)将行高设置为百分比时,没有任何反应。但是,如果我以像素为单位指定 - 一切都会发生。这怎么能解决?

html
  • 1 个回答
  • 18 Views
Martin Hope
XlAlbertlX
Asked: 2023-03-02 00:08:58 +0000 UTC

如何在字符串中找到特定的单词并将它们连同它们的索引一起输出?

  • 5

你需要做的是:在文本中找到“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 = "";
        }

请帮我解决这个问题

javascript
  • 3 个回答
  • 39 Views
Martin Hope
XlAlbertlX
Asked: 2022-12-27 20:23:41 +0000 UTC

程序跳过一行输入

  • 5

有一段代码:

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();

一切都输入正确,但代码总是在输入数字后跳过一行输入,但第二行工作正常。可能是什么问题呢?

java
  • 1 个回答
  • 23 Views
Martin Hope
XlAlbertlX
Asked: 2022-09-16 22:02:22 +0000 UTC

for 循环没有进行最后一次迭代

  • 0

我遇到了以下代码的问题:

#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 循环不进行最后一次迭代?

c++
  • 0 个回答
  • 0 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5