当我调用这个 promise 时,输出与函数调用的顺序不匹配。The.then出现在 之前.catch,即使.then之后调用了 with 的承诺。这是什么原因?
const verifier = (a, b) =>
new Promise((resolve, reject) => (a > b ? resolve(true) : reject(false)));
verifier(3, 4)
.then((response) => console.log("response: ", response))
.catch((error) => console.log("error: ", error));
verifier(5, 4)
.then((response) => console.log("response: ", response))
.catch((error) => console.log("error: ", error));Run Code Online (Sandbox Code Playgroud)
输出
node promises.js
response: true
error: false
Run Code Online (Sandbox Code Playgroud) 突然得到
SQLSTATE[HY000]:一般错误:1835 格式错误的通信数据包(SQL:select * from
tb_userswhere (username= 121211) limit 1)
在 Laravel 上。
我已经检查过这个:MySQL: ERROR 2027 (HY000): Malformed packet,但似乎是另一种情况。
但是我的 Laravel 出现了我之前提到的错误。有这方面的经验吗?
当我声明一个变量时,例如:
const FileId = Math.random().toString(36).substr(2, 9);
Run Code Online (Sandbox Code Playgroud)
我在声纳中收到此错误:
确保在这里使用这个伪随机数生成器是安全的。
我应该如何解决这个问题?我的代码有什么问题吗?
谁能帮我?
我可以使用存储过程创建表吗?
我正在使用 MySQL。我在网上搜索了有关如何使用存储过程创建表的说明,但没有找到任何结果,我只是发现您可以创建临时表。如果我使用存储过程创建表有什么问题吗?
其实我想检查一个表是否存在,然后我必须创建它。
ou's我有一个包含和的用户的活动目录记录subou's。我想得到AD的整个树形结构。
例如,
- Group A
- Sub Group a1
- Sub Group a2
- Group B
- Sub Group b1
- Sub Group b2
- Group C
- Sub Group c1
- Sub Group c2
Run Code Online (Sandbox Code Playgroud)
我有一份所有ou's和的清单subou's。但我希望它像上面的例子一样结构。
我的代码:
$ldap_base_dn = 'DC=example,DC=com';
$filter="(objectClass=organizationalunit)";
$arr= array("dn", "ou");
$sr=ldap_search($ldap_connection, $ldap_base_dn, $filter, $arr);
$info = ldap_get_entries($ldap_connection, $sr);
for ($i=0; $i < $info["count"]; $i++) {
echo $info[$i]["dn"]."<br>";
}
Run Code Online (Sandbox Code Playgroud) 我对 Axios 有一个小问题,我不知道如何在注册或登录后重定向。
这是我的代码:
axios.post("/api/user/signup", { data })
.then(res => {
if (res.status === 200) {
console.log("REDIRECTION avec status => ", res.status);
// how to redirect here
<Redirect to = {{ pathname: "/home" }} />
}
Run Code Online (Sandbox Code Playgroud)
流程到达console.log呼叫,但我无法在 React 中找到如何在它之后重定向。
我正在使用这个 jQuery 文件中的倒数计时器,但我想从中删除天数和小时数,因此它只显示分钟和秒。谁能帮我吗?数字从 png 文件显示,该文件在显示倒计时时创建翻转板效果。
jQuery.fn.countdown = function(userOptions)
{
// Default options
var options = {
stepTime: 60,
// startTime and format MUST follow the same format.
// also you cannot specify a format unordered (e.g. hh:ss:mm is wrong)
format: "dd:hh:mm:ss",
startTime: "01:12:32:55",
digitImages: 6,
digitWidth: 53,
digitHeight: 77,
timerEnd: function(){},
image: "digits.png"
};
var digits = [], interval;
// Draw digits in given container
var createDigits = function(where)
{
var c = 0;
// Iterate each startTime digit, if …Run Code Online (Sandbox Code Playgroud)这里我有一个 Bootstrap 模式。我的要求是当我使用提交按钮成功提交表单时,我想在几秒钟后关闭模式。这里的问题是,当我在输入中输入一些文本而不是整数时,或者如果我输入一些无效的输入,然后当我单击提交按钮时,输入字段会显示错误,并且模式会在几秒钟后立即关闭。
如果单击提交按钮时输入字段无效,我不想关闭引导模式。
我该怎么做 ?
编辑:它在有效输入的情况下完美工作。
html
<div class="modal-body">
<form action="">
<input type="number" name="rows" min="0" value="0" max="10" required><br>
<button type="submit" id="my_button" class="btn btn-info btn-sm">Submit</button>
</form>
</div>
Run Code Online (Sandbox Code Playgroud)
脚本
<script>
$('#my_button').click(function() {
setTimeout(function() {$('#myModal').modal('hide');}, 4000);
});
</script>
Run Code Online (Sandbox Code Playgroud) 我最近将 PHP 版本升级到 8.1-fpm,并将 Debian 升级到 Bullseye。我在某处读到 Bullseye 附带 AVIF 支持,但是当我尝试使用imageavif(),出现以下错误:
PHP message: PHP Fatal error: Uncaught Error: Call to undefined function imageavif()\nRun Code Online (Sandbox Code Playgroud)\n我在我的服务器上运行“php -i | grep AVIF”,它返回:
\nImageMagick supported formats => 3FR, 3G2, 3GP, AAI, AI, APNG, ART, ARW, AVI, AVIF, AVS, BGR, BGRA, BGRO, BIE, BMP, BMP2, BMP3, BRF, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CR3, CRW, CUR, CUT, DATA, DCM, DCR, DCX, DDS, DFONT, DNG, DPX, DXT1, DXT5, …Run Code Online (Sandbox Code Playgroud) 我正在尝试显示 ACF 的数据,但在 Visual Studio Code 中收到此错误:
这是整个代码。我尝试重新安装插件,将 PHP 添加到路径中,但似乎没有任何效果。
Single.php
<?php get_header();?>
<div class="container">
<div class="row">
<div>
<img src="<?php the_post_thumbnail_url('thumbnail'); ?>" id="single_header">
<div id="single_content">
<?php if (have_posts()):while (have_posts()):the_post(); ?>
<?php
$fn=get_the_author_meta('first_name');
$lname=get_the_author_meta('last_name');
$email=get_the_author_meta('email');
?>
<h1 class="text=cenetr nt-3 mb-5 text-primary"><?php the_title();?></h1>
<small>Publishor:<?php echo $fn; ?></small>
<p><?php the_content();?></p>
<?php
endwhile;
endif;
?>
<?php previous_post_link(); ?>
<?php next_post_link(); ?>
</div>
<div id="single_extraInfo">
<p>Company: <?php the_field('flight_company'); ?></p>
<p>Date: <?php the_field('flight_date'); ?></p>
<p>Capacity: <?php the_field('flight_capacity'); ?></p>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>
Run Code Online (Sandbox Code Playgroud) 我正在使用非常好的 Anychart 股票烛台图表,为了更新图表,我使用了一个setInterval函数,但它重新绘制了整个图表,这很糟糕,因为如果我正在缩放或某些东西,它会明显地重置并重新开始。有没有一种方法可以每隔几秒更新一次数据库中的最后价格而无需重新绘制整个图表?
当前setInterval加载图表的功能:
setInterval(function() {
$.get('chart_data.php', function(data) {
$(".main_cont").replaceWith(data);
});
}, 2000);
Run Code Online (Sandbox Code Playgroud)
我的图表数据变量:
$chart_data .= "{'x':'".$open_time."','open': ".$open.",'high': ".$high.",'low': ".$low.",'close': ".$close."},";
Run Code Online (Sandbox Code Playgroud)
chart_data.php 文件:
setInterval(function() {
$.get('chart_data.php', function(data) {
$(".main_cont").replaceWith(data);
});
}, 2000);
Run Code Online (Sandbox Code Playgroud)
我想setInterval用只替换数据库中的最后一个价格数据来向上或向下移动蜡烛的东西替换该函数,如果添加了新记录,则绘制新蜡烛。我有更新蜡烛图或添加新蜡烛图的脚本,如果不重新绘制整个图表,我就无法找到一种方法。
考虑这样一个数据库
显影剂表
+--------------+------+---------+
| developer_id | name | revenue |
+--------------+------+---------+
| 1 | John | 154,01 |
+--------------+------+---------+
Run Code Online (Sandbox Code Playgroud)
申请表
+--------------+------------------+-------+-------------+
| developer_id | application_name | price | sold_copies |
+--------------+------------------+-------+-------------+
| 1 | photo_app_1 | 0,79 | 123 |
+--------------+------------------+-------+-------------+
| 2 | photo_app_2 | 1,99 | 34 |
+--------------+------------------+-------+-------------+
Run Code Online (Sandbox Code Playgroud)
所以数据库:
price * sold_copies所有应用程序的总和这个数据库是规范化的吗?如果不是,它违反了哪种范式?