RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

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

Telion's questions

Martin Hope
Telion
Asked: 2020-10-24 10:56:39 +0000 UTC

更改数组的一个元素会覆盖整个数组

  • 1

该类有一个方法:

constructor(id) {
  this.position = [6, 4];
  this.LABYRINTH = init2DArray(8, 8, {lookaround: false, events: false});
  this.lookedaround.bind(this);
}

lookedaround() {
  //this.position задан в конструкторе: this.position = [6, 4];
  this.LABYRINTH[this.position[0]][this.position[1]].lookaround = true;
}

空白数组填充功能:

function init2DArray(xlen, ylen, data) {
  var ret = [];
  for (var x = 0; x < xlen; x++) {
    ret[x] = [];
    for (var y = 0; y < ylen; y++) {
      ret[x][y] = data;
    }
  }
  return ret;
}

当我简单地调用该方法时,lookedaround整个数组被覆盖,将每个值替换为true. 我不明白为什么会这样……

而已:

player.LABYRINTH.forEach((e, o) => {
  e.forEach((i, p) => {
    console.log(`[${o}, ${p}] = ${i.lookaround}`);
  });
});
[0, 0] = false
[0, 1] = false
[0, 2] = false
[0, 3] = false
[0, 4] = false
[0, 5] = false
[0, 6] = false
[0, 7] = false
[1, 0] = false
[1, 1] = false
[1, 2] = false
[1, 3] = false
[1, 4] = false
[1, 5] = false
[1, 6] = false
[1, 7] = false
[2, 0] = false
[2, 1] = false
[2, 2] = false
[2, 3] = false
[2, 4] = false
[2, 5] = false
[2, 6] = false
[2, 7] = false
[3, 0] = false
[3, 1] = false
[3, 2] = false
[3, 3] = false
[3, 4] = false
[3, 5] = false
[3, 6] = false
[3, 7] = false
[4, 0] = false
[4, 1] = false
[4, 2] = false
[4, 3] = false
[4, 4] = false
[4, 5] = false
[4, 6] = false
[4, 7] = false
[5, 0] = false
[5, 1] = false
[5, 2] = false
[5, 3] = false
[5, 4] = false
[5, 5] = false
[5, 6] = false
[5, 7] = false
[6, 0] = false
[6, 1] = false
[6, 2] = false
[6, 3] = false
[6, 4] = false
[6, 5] = false
[6, 6] = false
[6, 7] = false
[7, 0] = false
[7, 1] = false
[7, 2] = false
[7, 3] = false
[7, 4] = false
[7, 5] = false
[7, 6] = false
[7, 7] = false

player.lookedaround();

player.LABYRINTH.forEach((e, o) => {
  e.forEach((i, p) => {
    console.log(`[${o}, ${p}] = ${i.lookaround}`);
  });
});
[0, 0] = true
[0, 1] = true
[0, 2] = true
[0, 3] = true
[0, 4] = true
[0, 5] = true
[0, 6] = true
[0, 7] = true
[1, 0] = true
[1, 1] = true
[1, 2] = true
[1, 3] = true
[1, 4] = true
[1, 5] = true
[1, 6] = true
[1, 7] = true
[2, 0] = true
[2, 1] = true
[2, 2] = true
[2, 3] = true
[2, 4] = true
[2, 5] = true
[2, 6] = true
[2, 7] = true
[3, 0] = true
[3, 1] = true
[3, 2] = true
[3, 3] = true
[3, 4] = true
[3, 5] = true
[3, 6] = true
[3, 7] = true
[4, 0] = true
[4, 1] = true
[4, 2] = true
[4, 3] = true
[4, 4] = true
[4, 5] = true
[4, 6] = true
[4, 7] = true
[5, 0] = true
[5, 1] = true
[5, 2] = true
[5, 3] = true
[5, 4] = true
[5, 5] = true
[5, 6] = true
[5, 7] = true
[6, 0] = true
[6, 1] = true
[6, 2] = true
[6, 3] = true
[6, 4] = true
[6, 5] = true
[6, 6] = true
[6, 7] = true
[7, 0] = true
[7, 1] = true
[7, 2] = true
[7, 3] = true
[7, 4] = true
[7, 5] = true
[7, 6] = true
[7, 7] = true

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Telion
Asked: 2020-05-24 04:18:36 +0000 UTC

奇怪的背景位置行为

  • 1

当悬停在一个块上时,我想制作一个简单的动画。我想通过背景的移动来做所有的事情,而不是更进一步。通常,如果 viewport 有足够的高度background-position,它可以按我的需要工作,因此它将图像移动到块外 130% 的位置,但是对于较小的块,图像会向上而不是向下。我不明白为什么。我创建了一个交互式示例:

https://jsfiddle.net/Telion/g3h372mx/1/

setInterval(() => {
	$("#d").toggleClass("active");
}, 2000);
body {
  height: 20px;
}
body>div {
  background-image: url(https://cdn130.picsart.com/254265053013212.png);
  background-repeat: no-repeat;
  background-size: 350px 350px;
  background-position: -100px 200%;
  
  width: 300px;
  height: 400px;
  background-color: #000;
  transition: 0.5s;
}

.active {
  height: 250px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="d"></div>

你能告诉我为什么会发生这种情况,以及是否可以在不改变解决问题的方法的情况下解决它?

编辑: 可能值得添加一个原因。将鼠标悬停在块上将执行以下操作:https ://jsfiddle.net/Telion/g3h372mx/3/

html
  • 2 个回答
  • 10 Views
Martin Hope
Telion
Asked: 2020-04-20 14:55:47 +0000 UTC

按用户级别计算颜色

  • 7

重点是这个。随着时间的推移,用户通过使用该网站获得了经验。进度条的颜色随着用户的等级而变化。颜色可以通过 HEX 或 RGB 代码设置,但我很困惑。我确信这可以用一些数学公式来表达,但显然我没有学好数学。

级别就像一个数字序列:从 1 到无穷大。这是公式中唯一已知的参数。有必要以一种颜色从一种颜色到另一种颜色的非常平滑的方式来表达它。也就是说,如果之前的颜色是(0, 0, 5),那么下一个级别会将其更改为(0, 0, 6)。但这还不是全部。为了避免黑色和白色,我认为从蓝色过渡到绿色,然后从那里过渡到红色会更正确。如果颜色用完了,那么它们将继续使用新的颜色。

所以从 开始(0, 0, 255),然后是绿色(0, 255, 0),然后是红色(255, 0, 0)。但接下来要注意的是,每对颜色之间都会有一个所谓的中间色。例如,蓝色和绿色之间将是(0, 255, 255)。之后,蓝色将开始下降到 0。

在过去的 3 个小时里,我已经很好地打破了我的头,写了一篇关于需要做什么的完全不合逻辑的猜测。也许有人处理过类似的事情并会举出例子?或者至少在理论上暗示了如何做到这一点?

javascript
  • 3 个回答
  • 10 Views
Martin Hope
Telion
Asked: 2020-03-29 22:51:24 +0000 UTC

超出父级的块

  • 0

总的来说,一切似乎都很简单。有一个父级,它的宽度是800px。它有一个父级,它的宽度是父级的150%宽度,所以它超出了它。在您缩小浏览器窗口之前,一切正常。正因为如此,margin-left: 25%块在左边被正确地切断离开窗口,但在右边它有一个不对称的部分。所以它可以通过添加overflow:hidden到宽度为 的父级来修复100%,但是如果你进一步缩小它,这将不起作用,因为问题是,也没有滚动主要内容。

我在 JSFiddle 上创建了一个示例,因为您可以在那里使用视口的大小。尝试增加和缩小它,然后尝试添加overflow:hidden到.body.

https://jsfiddle.net/m6op1dwt/11/

我认为仍有可能不清楚,我会回答所有问题。感谢您的关注。

html
  • 1 个回答
  • 10 Views
Martin Hope
Telion
Asked: 2020-12-16 14:12:18 +0000 UTC

在 Jquery 中处理 HTML 对象

  • 0

我阅读了 HTML 页面的所有内容,然后将其显示在上面。唯一的区别是我想在脚本中更改页面的某些部分。于是就有了如下代码:

function getHTML() {
    return "<!DOCTYPE html>\n" + $('html')[0].outerHTML;
}

var page = getHTML();
$(".body-block pre code").text(page);

但我不知道如何使用page. 也就是说,例如,我想将内容更改"pre code"为任何其他文本,甚至不止一次。通常我会这样做:

$("pre code").text("Новый текст");

但

var page = getHTML();
console.log(page.find("pre code").text());

会报错:

jQuery.Deferred 异常:page.find 不是函数 TypeError:page.find 不是函数

项目中的 HTML 绝对是任何页面的代码,到目前为止,我只有基本的 HTML,我只是在测试新的想法:

<!DOCTYPE html>

<html lang="en">
<head>
  <meta charset="utf-8">

  <title>Tests</title>
  <meta name="description" content="Tests">
  <meta name="author" content="Telion">

  <link rel="stylesheet" href="assets/css/reset.css?v=1.0">
  <link rel="stylesheet" href="assets/css/main.css?v=1.0">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

  <!--[if lt IE 9]>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
  <![endif]-->
</head>

<body>
    <div class="body-block">
        <pre><code>Hello World!</code></pre>
    </div>

    <script src="assets/js/main.js"></script>
</body>
</html>

只想到正则表达式,但我不想打扰它们。这个问题有更好的解决方案吗?如果有更方便的选择,所有这些代码至少可以完全重写,我还没有想出更好的方法......

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Telion
Asked: 2020-11-15 03:51:16 +0000 UTC

React 中 setInterval 中的函数声明

  • 3

在学习 React 时,我发现了以下代码:

componentDidMount() {
    this.timerID = setInterval(
      () => this.tick(),
      1000
    );
}

他们为什么this.tick()站在前面()?如果我理解正确,是这种匿名函数声明吗?但毕竟它首先setInterval需要一个函数,而tick()这是这个类的一个方法,也就是说,它是一个函数。

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Telion
Asked: 2020-10-24 22:14:00 +0000 UTC

jQuery HTML 对象导航

  • 0

有类似的代码结构:

<div class="lang-line">
   <div class="sh-name">ab</div>
   <div class="lo-name">Abkhazian</div>
</div>
<div class="lang-line">
   <div class="sh-name">aa</div>
   <div class="lo-name">Afar</div>
</div>

我想设置一个快速的语言搜索,所以我将所有内容添加到 JQ 对象中:

$.each($('.langs .lang-line'), function() {
    l.push([$(this)]);
});

但我不知道如何使用这些对象。我需要用输入的名称检查它们的名称,如果匹配,则应隐藏所有其他对象,并且该对象应保持可见:

这是我试图实现的:

for (var j=0; j<strArray.length; j++) {
    console.log(strArray[0].{0}.innerText);
    if (strArray[j][0][0][1].toLowerCase().match(str.toLowerCase())) {
        output.push(strArray[j].text());
        $(".lang-line").addClass("lang-line-srchprog");
        strArray[j].parent().style("display", "table");
    }
}

output- 包含稍后将显示的信息的数组; strArray- 相同的数组l只被函数接收; str- 用户输入的文本(用户输入他想在输入中找到的内容)。

这是对象本身的样子: 在此处输入图像描述

如何访问所有这些选项?特别是,我需要 innerText/textContent 来同时比较短名称和长名称(因为它读取所有孩子的内容,对吧?)

html
  • 1 个回答
  • 10 Views
Martin Hope
Telion
Asked: 2020-06-14 19:19:28 +0000 UTC

FormData 的表单对象

  • 0

我遇到了一个烦人的问题。

data: new FormData($('form')[0])

效果很好,但是:

$("form").submit(function(e) {

  sendData($(this));
  e.preventDefault();

});

function sendData(submitForm) {

   ...

   data: new FormData(submitForm)

不起作用。我不明白为什么。我检查并确保 submitForm 填满了表单数据和相关信息。那么究竟是什么问题以及如何解决呢?

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Telion
Asked: 2020-06-04 18:10:58 +0000 UTC

504 网关超时 Winginx

  • 3

首先,我在计算机的系统文件夹中安装了 Winginx,非常徒劳..我很晚才意识到这一点。一切正常,直到我不得不在服务器上使用文件并将服务器移动到另一个位置。删除整个 WinGinx 文件夹,启用安装程序,在“C:\Winginx”中重新安装它。

我检查了本地主机,一切正常,添加了一个新项目,将文件从以前的服务器扔到那里,我得到“504 网关超时”。我忍受了很长时间的超时,设置fastcgi_connect_timeout 10;了它,但那是 10 秒的无用等待,在那之前我什至没有添加任何东西来使网站正常工作。

localhost/phpinfo.php 工作正常,但其他项目由于某种原因不运行 php 文件。默认情况下,localhost 没有自己的配置,我没有设置任何东西。任何项目都由除 .php 之外的所有文件加载。

连接时我在日志中收到以下错误:

[notice] 信号进程开始

[error] 16060#7760: *17 upstream timed out (10060: A connection attempt failed because the connected party didn't properly response after a period time, or established connection failed because connected host has failed respond) 连接上游时,客户端:127.0.0.1,服务器:我的域,请求:“GET/HTTP/1.1”,上游:“fastcgi://127.0.0.1:9000”,主机:“我的域”

这是什么?上次一切都很好!而且,他说超时没有问题,这不可能。该站点未加载任何内容,上次我没有更改超时。另外,我将超时设置为 60 秒,这只是将等待时间拖到了 504 错误。

我在网上翻遍了这个主题,找到了有关 php-fpm 的信息,但我仍然不明白它是什么以及为什么,虽然很多人要求为此配置,但我没有任何地方,我查了一下一切。

nginx 配置中有一行:

fastcgi_pass localhost:9071;

站点配置中有类似的行:

fastcgi_pass 127.0.0.1:9000;

当我查看哪些端口在忙什么时,我注意到 9000 端口根本没有,而 9071 端口被 php-cgi.exe 进程占用了。(虽然默认应该是 9000 端口,我也没有改什么)。

我正在使用 Winginx,Windows 10,nginx 版本 1.12.0,PHP 版本 7.1.5。如果您需要任何其他信息 - 请询问,我不确定还应该提供什么来解决问题。

感谢您的关注!


站点配置如下所示,我什至没有更改它们:

server {
	listen 127.0.0.1:80;
	server_name music-portfolio.com www.music-portfolio.com;

	root home/music-portfolio.com/public_html/;

	index index.php index.html;

	log_not_found off;
	access_log logs/music-portfolio.com-access.log;

	charset utf-8;

	location ~ /\. { deny all; }
	location = /favicon.ico { }
	location = /robots.txt { }

	location ~ \.php$ {
		fastcgi_pass 127.0.0.1:9000;
		fastcgi_index index.php;
		fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
		include fastcgi_params;
	}
	


}

nginx.conf:

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

pid        temp/nginx.pid;


events {
    worker_connections  1024;
}


http {
	server_names_hash_bucket_size 128;

    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    client_max_body_size 55m;

    #gzip  on;

	scgi_temp_path  temp/uwsgi_temp 1 2;
	uwsgi_temp_path  temp/uwsgi_temp 1 2;

	fastcgi_connect_timeout 1;


	server {
		listen   127.0.0.1:80;

		root home/localhost/public_html;
		index index.php index.html;

		log_not_found off;
        charset utf-8;

		access_log  logs/access.log  main;

		location ~ /\. {deny all;}

		location / {

			if ($host ~ ^(www\.)?([a-z0-9\-\.]+)$){
				root home/$2/public_html;
				access_log  logs/$2-access.log  main;
			}

		}

        location ~ \.php$ {

			if ($host ~ ^(www\.)?([a-z0-9\-\.]+)$){
				root home/$2/public_html;
				access_log  logs/$2-access.log  main;
			}

			if (!-e $document_root$document_uri){return 404;}
			fastcgi_pass localhost:9071;
			fastcgi_index index.php;
			fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

			include fastcgi_params;

        }
	}

	server {
		listen 127.0.0.1:443;
		include ssl.conf;

		root home/localhost/public_html;
		index index.php index.html;

		log_not_found off;
        charset utf-8;

		access_log  logs/access.log  main;

		location ~ /\. {deny all;}

		location / {

			if ($host ~ ^(www\.)?([a-z0-9\-\.]+)$){
				root home/$2/public_html;
				access_log  logs/$2-access.log  main;
			}

		}

        location ~ \.php$ {

			if ($host ~ ^(www\.)?([a-z0-9\-\.]+)$){
				root home/$2/public_html;
				access_log  logs/$2-access.log  main;
			}

			if (!-e $document_root$document_uri){return 404;}
			fastcgi_pass localhost:9071;
			fastcgi_index index.php;
			fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

			include fastcgi_params;

        }
	}


	include tools-*.conf;

	include vhosts/*.conf;

}

nginx
  • 4 个回答
  • 10 Views
Martin Hope
Telion
Asked: 2020-05-18 00:39:00 +0000 UTC

为什么需要 AngularJS 后端?

  • 1

我最近开始学习 AngularJS。但是我认为,如果很难在其上托管站点,那将不会很酷,因此应该提前考虑这个问题。

正如我从英语资源中了解到的那样,运行您的应用程序不需要 NodeJS,因为所有操作都可以由客户端在本地处理。

那么 AngularJS 的意义何在?为了简化部分工作?在服务器上处理数据方面,会有某种PHP吧?然后 AngularJS 就可以轻松地处理页面上的元素。

最后一件事:是否可以将 TS 脚本附加到页面来执行它?也就是说,不需要为“客户端”版本重写程序。也就是说,再一次,服务器和客户端版本看起来一样吗?

angularjs
  • 1 个回答
  • 10 Views
Martin Hope
Telion
Asked: 2020-05-09 23:49:22 +0000 UTC

通过控制台查看函数变量的值

  • 2

您需要通过控制台找出在函数中声明且在全局空间中无法访问的变量的值。我不明白如何在谷歌浏览器中请求这个值。试图处理断点,说变量没有声明,也没有声明。

function check() {
    var variable = 100;
}

您不能简单地请求一个变量variable,因为它是在函数中声明的。

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Telion
Asked: 2020-04-20 01:07:23 +0000 UTC

Javascript 中的自定义音频播放器

  • 0

我在 Google 上搜索了大约 100 个不同的播放器,但这很有趣。我确信我可以很容易地找到许多库来使用,但我找不到任何合适的库。

我需要一个能够从 soundcloud 下载音乐的站点的固定播放器(但在极端情况下没有它也是可能的)和一个播放列表。同样重要的是,它是可定制的,以便根据网站的设计进行调整。同时,它具有自适应性,使其在移动设备上也能高效工作。

我找到了这个播放器:http ://www.mediaelementjs.com/ ,但它没有任何自适应性?所以要将它附加到页面底部,您将不得不重写一半的样式和脚本。好吧,它不支持列表,原则上也可以通过它们的 API 来解决。

我想知道:也许有人已经处理过这个问题?你是怎么解决的?我不想从头开始编写脚本。

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Telion
Asked: 2020-04-12 00:08:02 +0000 UTC

使用 scrollSpeed 平滑滚动

  • 0

我找到了一个使用 Jquery 创建平滑滚动的便捷选项。一切都会好起来的,但有 1 个问题/错误。在中心某处更新页面后,浏览器会自动将我移动到那里,但脚本开发人员显然没有预见到这一点,如果我转动鼠标滚轮,我会移动到页面的最开头。

我已经尝试修复此问题,我发现问题出在root最初始终为 0 的变量的可见性中。我尝试为其设置 wheelDeltaY 或 wheelDelta、deltaY 的高度,但由于某种原因它不起作用.

你能看一下脚本代码并更正它吗?感谢您的关注。

一个JSFiddle上的例子会更方便,下面是按照规则的代码。

$(function() {
        $.scrollSpeed(100, 450);
    });
	
	// Plugin: jQuery.scrollSpeed
// Source: github.com/nathco/jQuery.scrollSpeed
// Author: Nathan Rutzky
// Update: 1.0.2

(function($) {
    
    jQuery.scrollSpeed = function(step, speed, easing) {
        
        var $document = $(document),
            $window = $(window),
            $body = $('html, body'),
            option = easing || 'default',
            root = 0,
            scroll = false,
            scrollY,
            scrollX,
            view;
            
        if (window.navigator.msPointerEnabled)
        
            return false;
            
        $window.on('mousewheel DOMMouseScroll', function(e) {
            
            var deltaY = e.originalEvent.wheelDeltaY,
                detail = e.originalEvent.detail;
                scrollY = $document.height() > $window.height();
                scrollX = $document.width() > $window.width();
                scroll = true;
            
            if (scrollY) {
                
                view = $window.height();
                    
                if (deltaY < 0 || detail > 0)
            
                    root = (root + view) >= $document.height() ? root : root += step;
                
                if (deltaY > 0 || detail < 0)
            
                    root = root <= 0 ? 0 : root -= step;
                
                $body.stop().animate({
            
                    scrollTop: root
                
                }, speed, option, function() {
            
                    scroll = false;
                
                });
            }
            
            if (scrollX) {
                
                view = $window.width();
                    
                if (deltaY < 0 || detail > 0)
            
                    root = (root + view) >= $document.width() ? root : root += step;
                
                if (deltaY > 0 || detail < 0)
            
                    root = root <= 0 ? 0 : root -= step;
                
                $body.stop().animate({
            
                    scrollLeft: root
                
                }, speed, option, function() {
            
                    scroll = false;
                
                });
            }
            
            return false;
            
        }).on('scroll', function() {
            
            if (scrollY && !scroll) root = $window.scrollTop();
            if (scrollX && !scroll) root = $window.scrollLeft();
            
        }).on('resize', function() {
            
            if (scrollY && !scroll) view = $window.height();
            if (scrollX && !scroll) view = $window.width();
            
        });       
    };
    
    jQuery.easing.default = function (x,t,b,c,d) {
    
        return -c * ((t=t/d-1)*t*t*t - 1) + b;
    };
    
})(jQuery);
<!DOCTYPE html>
<html><head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

</head>
<body>
    <h1><b>jQuery.scrollSpeed</b> is a lightweight jQuery extension for
    custom scrolling speed in modern web browsers. Supports vertical or
    horizontal scrolling direction, including user-defined easing.
    Singapore conversation business class, vibrant sharp Swiss Ettinger bespoke
    Lufthansa discerning Toto handsome. Bulletin sleepy conversation hand-crafted
    international. Washlet alluring elegant, Sunspel charming vibrant Swiss the
    best Helsinki liveable lovely Singapore flat white intricate. Boulevard
    Tsutaya discerning uniforms Zürich Sunspel Ettinger perfect first-class St
    Moritz bespoke. Cutting-edge bulletin soft power concierge vibrant the
    best. Ginza charming impeccable, izakaya hand-crafted global Lufthansa soft
    power. Alluring Fast Lane hub, pintxos St Moritz intricate Nordic wardrobe
    first-class boutique Boeing 787. Business class carefully curated global,
    izakaya airport Helsinki Ettinger Melbourne. International cosy liveable
    Sunspel ryokan Washlet ANA signature joy artisanal. Hand-crafted pintxos
    bespoke soft power. Charming lovely pintxos Melbourne Toto bureaux
    Singapore first-class. Impeccable Porter exquisite quality of life
    liveable. Pintxos boulevard ryokan sophisticated handsome Sunspel Baggu
    elegant wardrobe signature Zürich hub Ginza eclectic Beams. Airbus A380
    Shinkansen bespoke, Helsinki Baggu ANA bulletin cutting-edge Swiss Gaggenau
    elegant hand-crafted Singapore. Marylebone St Moritz emerging espresso
    Swiss. Conversation boulevard destination Ettinger, Gaggenau St Moritz
    artisanal sleepy pintxos Beams Shinkansen business class Nordic emerging.
    St Moritz artisanal eclectic the best, joy Baggu Washlet wardrobe Comme des
    Garçons vibrant Beams Swiss. K-pop pintxos liveable exclusive the best
    global smart flat white remarkable Zürich Scandinavian tote bag Baggu
    hand-crafted. Elegant pintxos Baggu Beams Swiss. Elegant Asia-Pacific
    pintxos izakaya bespoke, vibrant flat white exquisite. Intricate
    Scandinavian finest Baggu Gaggenau smart elegant Helsinki Airbus A380
    Swiss. Bureaux smart Nordic, Lufthansa Ginza Singapore extraordinary
    cutting-edge ryokan lovely Comme des Garçons perfect liveable joy Muji.
    Global craftsmanship intricate, flat white Helsinki Winkreative Beams
    izakaya airport ryokan artisanal Ettinger handsome Toto.</h1>

 </body></html>

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Telion
Asked: 2020-03-26 19:54:52 +0000 UTC

块的切角

  • 13

您需要切割块的角,以便切割部分的背景是透明的。背景将是图像,因此三角形不起作用。在这种情况下,切掉部分的整个块必须有框架,因此存在问题。

我用创建了一个切片器clip-path,但是盒子边框就像盒子本身一样被切片了。结果,结果是这样的:

例子

html,
body,
.bdiv,
.mainblock {
    height: 100%;
    width: 100%;
    overflow: hidden;
}
.bdiv {
    display: table;
}
.mainblock {
    display: table-cell;
    vertical-align: middle;
}
.mainblock>div {
    position: relative;
    width: 500px;
    background: #444;
    margin: 0 auto;
}
.content {
    padding: 10px 30px;
    text-align: center;
    font-size: 16px;
    font-family: sans-serif;
    color: ddd;
}
.head-text {
    clip-path: polygon(460px 0, 100% 30px, 100% 100%, 0 100%, 0 0);
    font-size: 18px;
    color: #eee;
    border: 5px solid #fff;
    background: #333;
}
.cont-text {
    background: #000;
}
.cont-text>form input {
    padding: 5px;
    width: 40%;
}
<html>
<body style="background: #444;">
<div class="bdiv">

	<div class="mainblock">
		<div>
			<div class="content head-text">Приветствую!</div>
			<div class="content cont-text">
				<form>
					<input type="button" value="Привет">
					<input type="button" value="Пока">
				</form>
			</div>
		</div>
	</div>

</div>
</body>
</html>

当然,您可以在切片顶部添加一个绝对块线作为框架,但我认为这还没有完成。但那又如何呢?我需要 2 个这样的切口,一个如图所示,第二个在下方左侧。

html
  • 4 个回答
  • 10 Views
Martin Hope
Telion
Asked: 2020-03-04 00:38:42 +0000 UTC

路由器降速

  • 2

如果我转向了错误的 StackOverflow 网络资源,我深表歉意,如果是这样,请通过关闭问题的请求通知我。

供应商提供 1 吉位,但路由器甚至没有分配完整的 54 兆位。(测试结果)我与提供商的顾问进行了交谈,他们确定一切都直接通过电缆进行,因为最大值直接进行(通过路由器的电缆)。但是,从上面的测试可以看出,只有“理论上的 100Mbit”通过 Wi-Fi。

计算机有一个内置的 TP-Link 适配器型号TL-WN722N ,速度为 150Mbps,支持 802.11n 并在此模式下与此路由器一起工作(至少它工作的应用程序是这么说的)。路由器配置为 11bgn 混合模式。

千兆路由器TP-Link型号TL-WR1043ND V4。已从官方网站更新到最新固件。理论上它应该分配所有 300 Mbps,但看起来它分配了大约 100。路由器自动确定实际干扰最少的信道。

我也知道路由器无论如何都会降低速度,但关键是在将关税从 100 Mbps 更改为 1 Gbps 后,速度没有改变,但应该增加(再次理论上)10 倍。也许我错过了什么,还有什么可以阻止我接收完整的 150-300Mbps?

wifi
  • 1 个回答
  • 10 Views
Martin Hope
Telion
Asked: 2020-12-31 02:06:58 +0000 UTC

从文件数据创建数组

  • 0

我有一个文件,其结构如下所示:

33,40,43,45,47,49
34,40,41,45,46,48
36,40,43,45,46,48
15,39,43,44,47,49
35,40,42,45,47,49
...

我正在尝试加载文件数据并将其中的所有内容写入一维数组,重要的是它最终是数字。有一种选择,但在我看来它效率低下,因为使用现有的 JS 函数可以更轻松地完成所有事情。

我的版本看起来像这样并且不起作用,因为有多少东西我没有尝试过 - 未定义或出现字符串。例如,我不明白如何用其他数组扩展一个数组(一维),使其数据变成数字。

if (window.File && window.FileReader && window.FileList && window.Blob) {
	document.getElementById('file').addEventListener('change', function(e) {
	var file = e.target.files[0];
	var reader = new FileReader();
	reader.onload = function(e) {
		var text = e.target.result;
		var newarray = text.split('\n');
		for (i=0; i<newarray.length; i++) {array.concat(newarray[i].split(','));}
		for (i=0; i<array.length; i++) array[i] = Math.floor((array[i]/50)*100)/100;
		for (i=0; i<array.length-501; i++) {
			array2.push([array.slice(i,i+500), [array[i+501]]]);
		}
	};
	  
	reader.readAsText(file);
	});
} else {
	alert('File API is not supported!');
}

好吧,之后我根据给定的数据制作了另一个数组。除了再次强调必须将所有数据写入一维数组之外,这不会影响任何其他内容。

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Telion
Asked: 2020-12-18 08:26:03 +0000 UTC

有关阵列及其数据的完整信息

  • 0
  • 如何确定一个数组是否是一个完整的数组,而不是一个字符串或某种“非数组”?

我期待某种var_dump类似于 PHP 的函数,但在 JS 中我无法弄清楚数组数据是什么类型以及如何通常确定数组是真实的并且可以使用标准方法来处理数组。

  • 如何找出数组变量的类型并将其更改为另一个?

我的数组存储了数以千计的数据,但它在脚本过程中被部分调节,因此它的类型可能已被更改。有没有办法找出数据类型并将其更改为所需的类型?

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Telion
Asked: 2020-12-01 04:55:04 +0000 UTC

在前一个旁边放置一个浮动块

  • 0

我写了这段代码。计划在每个块的左侧有一张图片,右侧在顶部有一个名称,在底部有一个描述。但问题是带有文本的块,由于其长度,占据了块的所有 100%,并被转移到下一行。

如何让文字不换行,同时保持灵活性,即不设置块的宽度,以后可以不断变化?

JSFiddle:https ://jsfiddle.net/6arnozcs/

.clearfix:after {
  content: "";
  display: table;
  clear: both;
}
.shop_block {
	max-height: 300px;
	overflow: auto;
    width: 400px;
}
.shop_item {
    background: #ccc;
}
.shop_item:hover {
	background: #999;
}
.shop_item>div {
	float: left;
}
.shopitem_cont {
	height: 64px;
    overflow: hidden;
	box-sizing: border-box;
	padding: 5px 10px 3px 8px;
}
.shopitem_head {
	font-size: 18px;
	padding: 0 0 3px 0;
	margin: 0 0 3px 0;
	border-bottom: 1px solid #000;
}
<div class="shop_block">
		<div class="shop_item clearfix">
			<div class="shopitem_image">
				<img src="http://placehold.it/64x64">
			</div>
			<div class="shopitem_cont">
				<div class="shopitem_head">Item 0</div>
				Description is here. На самом деле описание настоооолько большое что просто  не влазит в этот блок. 
			</div>
		</div>
		<div class="shop_item clearfix">
			<div class="shopitem_image">
				<img src="http://placehold.it/64x64">
			</div>
			<div class="shopitem_cont">
				<div class="shopitem_head">Item 0</div>
				Description is here. На самом деле описание настоооолько большое что просто не влазит в этот блок. 
			</div>
		</div>
	</div>

html
  • 1 个回答
  • 10 Views
Martin Hope
Telion
Asked: 2020-11-01 23:52:57 +0000 UTC

由 XML 构成的数组结构的问题

  • 0

我创建一个数组:

$tv = simplexml_load_file('output/'.$xml);

我用 foreach 遍历它:

foreach ($tv as $tvinfo):
if ($tvinfo['channel'] != ''){
$channel=$tvinfo['channel'];
}

但这只是其价值所在的频道或标签的标识符(我不确定)。我正在尝试获取名称,例如“Channel 1”(位于[id])。

echo $tv['channel'][0]->display-name;

但我不知道如何去做。途中有对象,我不知道如何与它们交互,我还没有想出如何在循环中完成所有操作,获取名称而不是标识符。

我附上了 XML 数组结构:

SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [source-info-url] => http://cherrytest.com/
            [source-info-name] => CherryTest
            [generator-info-name] => XMLTV/: tv_grab_na_dd.in,v 1.70 2008/03/03 15:21:41 rmeden Exp $
            [generator-info-url] => http://www.xmltv.org/
        )

    [channel] => Array
        (
            [0] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                        (
                            [id] => Канал 1
                        )

                    [display-name] => Канал 1
                )

            [1] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                        (
                            [id] => Канал 2
                        )

                    [display-name] => Канал 2
                )

        )

    [programme] => Array
        (
            [0] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                        (
                            [start] => 20161104121212 +0200
                            [stop] => 20161105215224 +0200
                            [channel] => 0
                        )

                    [title] => Передача 1
                    [desc] => Описание отсутствует.
                    [date] => 20161104
                    [audio] => SimpleXMLElement Object
                        (
                            [stereo] => stereo
                        )

                )

            [1] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                        (
                            [start] => 20161108121212 +0200
                            [stop] => 20161109215225 +0200
                            [channel] => 0
                        )

                    [title] => Передача 2
                    [desc] => Описание второй передачи. Йеее.
                    [date] => 20161108
                    [audio] => SimpleXMLElement Object
                        (
                            [stereo] => stereo
                        )

                )

            [2] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                        (
                            [start] => 20161112121212 +0200
                            [stop] => 20161113215226 +0200
                            [channel] => 1
                        )

                    [title] => Передача 3
                    [desc] => Описание отсутствует.
                    [date] => 20161112
                    [audio] => SimpleXMLElement Object
                        (
                            [stereo] => stereo
                        )

                )

        )

)

XML 文件本身:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tv SYSTEM 'xmltv.dtd'>
<tv source-info-url="http://cherrytest.com/" source-info-name="CherryTest" generator-info-name="XMLTV/: tv_grab_na_dd.in,v 1.70 2008/03/03 15:21:41 rmeden Exp $" generator-info-url="http://www.xmltv.org/">
	<channel id="Канал 1">
		<display-name>Канал 1</display-name>
	</channel>
	<channel id="Канал 2">
		<display-name>Канал 2</display-name>
	</channel>
	<programme start="20161104121212 +0200" stop="20161105215224 +0200" channel="0">
		<title lang="ua">Передача 1</title>
		<desc lang="ua">Описание отсутствует.</desc>
		<date>20161104</date>
		<audio>
			<stereo>stereo</stereo>
		</audio>
	</programme>
	<programme start="20161108121212 +0200" stop="20161109215225 +0200" channel="0">
		<title lang="ua">Передача 2</title>
		<desc lang="ua">Описание второй передачи. Йеее.</desc>
		<date>20161108</date>
		<audio>
			<stereo>stereo</stereo>
		</audio>
	</programme>
	<programme start="20161112121212 +0200" stop="20161113215226 +0200" channel="1">
		<title lang="ua">Передача 3</title>
		<desc lang="ua">Описание отсутствует.</desc>
		<date>20161112</date>
		<audio>
			<stereo>stereo</stereo>
		</audio>
	</programme>
</tv>

如果它对任何人都有用,我按照下面描述的方式解决了属性问题,否则非常感谢@Aleksey Shimansky

$number = (int) $tvinfo['channel'];                  //конвертировал в int
$real_channel = $tv->channel[$number]->attributes(); //так как у меня цикл и каналы могут повторятся для разных передач я достаю соответствующий канал
$channel=$real_channel;
php
  • 2 个回答
  • 10 Views
Martin Hope
Telion
Asked: 2020-10-28 05:05:38 +0000 UTC

将数组推入数组会创建一个空数组数组

  • 0

打破了他的头。

首先在一个循环中for:for (var j = 0; j <= 7; j++)ipush current_position.push(j);结果,生成了一个像这样的数组:

var current_position = [];
var cursor = 0; 

function queens8() {
    for (var j = 0; j <= 7; j++) {
        if (check(cursor, j) == true) {

            cursor++;
            current_position.push(j);

            if (current_position.length == 8) {

                done_positions.push(current_position);

                console.log(current_position);    
                //выводит на первой итерации: [0, 4, 7, 5, 2, 6, 1, 3]

            }
            queens8();
        }
    }
    current_position.splice(cursor-1, 1);
    cursor--;
    return;
}

但是如果你像这样收集另一个数组中的所有数组:

done_positions.push(current_position);

我得到这样的东西:

[Array[0], Array[0], Array[0], Array[0], Array[0], Array[0], ...]

所以所有 120 次都通过了。为什么它们是空的,如何使它们不空?


更新:我解决了这个问题,但我不明白它为什么起作用:

done_positions.push([]+current_position);
javascript
  • 1 个回答
  • 10 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