小编shr*_*rys的帖子

RTCPeerConnection m 线与报价不匹配

我正在开发一个 WebRTC 视频流程序,当用户想要添加视频流时,该程序必须能够重新协商 rtc 连接。因为它是我的程序关闭现有的 RTCPeerConnection 设置变量Connectionnull然后创建一个新的 RTCPeerConnection 并重新启动提供/应答交换。

我收到错误:

无法设置远程应答 sdp:应答中的 m 行顺序与报价中的顺序不匹配。拒绝回答。

设置初始连接后。

尽管连接已完全关闭并在两端设置为空,但为什么会发生这种情况?

javascript webrtc rtcpeerconnection

6
推荐指数
0
解决办法
4147
查看次数

json-server db.json 中带有“/”的路径

我使用server-json来创建一个假 API,我在 data.json 中有路径“playbook/active”

"playbook/active": [{
    "description": "This playbook will install haproxy",
    "name": "Testing playbook 3",
    "tag": [
      "loadbalancer",
      "charge"
    ],
    "path": "/etc/ansible/haproxy.yml",
    "type": "action",
    "id": "4bb107be-9efe-11e9-b3e5-bc5ff4901aa5"
  },
  {
    "path": "google.com",
    "description": "This is the playbook before execution",
    "tag": [
      "webserver",
      "tomcat"
    ],
    "id": "faa746b4-9cb7-11e9-9b94-bc5ff4901aa5",
    "name": "mysql"
  }
]
Run Code Online (Sandbox Code Playgroud)

但我有这个错误

错误:哎呀,在数据库属性“playbook/active”中找到/字符。

我更改为“playbook/active”但同样的错误

javascript json-server

6
推荐指数
1
解决办法
8349
查看次数

HTML自定义表单元素不发送提交事件

创建了一个从 HTMLFormElement 派生的自定义 HTML 元素,并在构造函数中添加了“提交”事件的侦听器。该元素已正确注册,但提交处理程序从未被调用...

class MyForm extends HTMLFormElement {
  constructor() {
    super();
    this.addEventListener('submit', this.mySubmit);
  }

  mySubmit() {
    console.log('mySubmit was called');
  }

  connectedCallback() {
    console.log('Custom form element added to page.');
  }
}

customElements.define('my-form', MyForm, {
  extends: 'form'
});
Run Code Online (Sandbox Code Playgroud)
<!DOCTYPE html>
<html lang="de-DE">

<head>
  <title>My Form</title>
  <meta charset="utf-8">
  <!--<script src="myform.js" async="true"></script>-->
</head>

<body>
  <h1>My Form</h1>
  <my-form>
    <p><input type="input" value="Whoa!" /></p>
    <p><button type="submit">Submit</button></p>
  </my-form>
</body>

</html>
Run Code Online (Sandbox Code Playgroud)

javascript

5
推荐指数
1
解决办法
975
查看次数

初始化 Vue Native 项目时如何修复“ENOENT:没有这样的文件或目录,chdir 'project-name'”?

我正在尝试:
vue-native init test-project
我得到了这个输出:
使用全局安装的 expo-cli 3.0.10

创建 Vue Native 项目 project-new

  • 使用 expo-cli 创建项目

[09:09:29] --name:在非交互模式下需要参数。? 使用 expo-cli 创建项目

(node:9072) UnhandledPromiseRejectionWarning: E​​rror: ENOENT: no such file or directory, chdir 'project-new' at process.chdir (internal/process/main_thread_only.js:31:12) at installPackages (C:\Users\User\ AppData\Roaming\npm\node_modules\vue-native-cli\src\index.js:182:11) 在 createExpoProject (C:\Users\User\AppData\Roaming\npm\node_modules\vue-native-cli\src\ index.js:123:3) 在 init (C:\Users\User\AppData\Roaming\npm\node_modules\vue-native-cli\src\index.js:101:5) 在命令。(C:\Users\User\AppData\Roaming\npm\node_modules\vue-native-cli\src\index.js:69:7) 在 Command.listener (C:\Users\User\AppData\Roaming\npm\ node_modules\vue-native-cli\node_modules\commander\index.js:315:8) at Command.emit (events.js:182:13) at Command.parseArgs (C: \Users\User\AppData\Roaming\npm\node_modules\vue-native-cli\node_modules\commander\index.js:651:12) 在 Command.parse (C:\Users\User\AppData\Roaming\npm\node_modules \vue-native-cli\node_modules\commander\index.js:474:21) 在 Object. (C:\Users\User\AppData\Roaming\npm\node_modules\vue-native-cli\src\index.js:81:9) (node:9072) UnhandledPromiseRejectionWarning:未处理的承诺拒绝。这个错误要么是因为在没有 catch 块的情况下抛出了异步函数,要么是因为拒绝了一个没有用 .catch() 处理过的承诺。(rejection id: 1) (node:9072) [DEP0018] DeprecationWarning:不推荐使用未处理的承诺拒绝。将来,未处理的承诺拒绝将使用非零退出代码终止 Node.js 进程。\Users\User\AppData\Roaming\npm\node_modules\vue-native-cli\node_modules\commander\index.js:474:21) 在 Object. …

native npm vue.js react-native vue-native

5
推荐指数
0
解决办法
538
查看次数

Can any one explain this strange behavior about Array sort?

I have a array like this

a = [0, "-", "-", "-", "-", "-", -0.2, -0.05, 0.25, 0.47, 0.875].

notice that there are some '-' in this array and only this string appears and the left are numbers.

now I apply sort on this array, just like

a = [0, "-", "-", "-", "-", "-", -0.2, -0.05, 0.25, 0.47, 0.875];
console.log(a.sort((a, b) => (+a || -Infinity) - (+b || -Infinity)));
Run Code Online (Sandbox Code Playgroud)

or

a = [0, "-", "-", "-", "-", "-", …
Run Code Online (Sandbox Code Playgroud)

javascript arrays sorting

3
推荐指数
1
解决办法
91
查看次数

concat在javascript中的语法

let items = ['Tom','Bill','Kim'];
let result = items.reduce((str, item) => str + '<'.concat(item).concat('>'),"");

console.log(result);
Run Code Online (Sandbox Code Playgroud)

请问""代码的结尾是什么?

javascript reduce concat function

2
推荐指数
1
解决办法
53
查看次数

运算符'+'不能应用于类型'number []':如何纠正构建错误?

以下函数生成uuidv4字符串。

function uuidv4() {
  return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
    (
      c ^
      (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))
    ).toString(16)
  );
}
console.log(uuidv4());
Run Code Online (Sandbox Code Playgroud)

使用打字稿时,当我尝试构建时,出现错误消息:

TS2365: Operator '+' cannot be applied to types 'number[]' and '-1000'.
Run Code Online (Sandbox Code Playgroud)

如何使用打字稿成功构建相同的功能?

javascript typescript

1
推荐指数
1
解决办法
48
查看次数

排序日期数组的麻烦

我有一个奇怪的问题,就是日期数组未完全排序。数组的大多数似乎正确排序,但是奇怪的是,数组中的前两个元素未排序或排序不正确。

码:

var arrSortTest = ["July 11, 1960", "February 1, 1974", "July 11, 1615", "October 18, 1851", "November 12, 1995"];

for (var i = 0; i < arrSortTest.length; i++) {
  arrSortTest.sort(function(i) {
    var temp = new Date(i);
    return temp
  });
}
console.log(arrSortTest)
Run Code Online (Sandbox Code Playgroud)

我的期望: ["July 11, 1615", "October 18, 1851", "July 11, 1960", "February 1, 1974", "November 12, 1995"]

我得到的是: ["October 18, 1851", "July 11, 1615", "July 11, 1960", "February 1, 1974", "November 12, 1995"]

上面的代码似乎应该可以正常工作,并且似乎在大多数情况下都可以。我应该在这里做些什么以使测试数组中的日期从最旧到最新排序?我只是不了解如何对带有日期的数组进行排序?

先感谢您。

javascript

0
推荐指数
1
解决办法
38
查看次数

如果用户向下滚动(水平滚动),则向左滚动

我正在开发一个水平网站,当用户向下滚动时我需要进行水平滚动。有什么想法如何用 javascript 实现这一点吗?

这是小提琴: https: //jsfiddle.net/erqbtL23/

这是代码:

body {
  margin: 0;
  height: 100vh;
}

* {
  box-sizing: border-box;
}

.container {
  overflow-x: auto;
  white-space: nowrap;
}

.container>div {
  background: red;
  display: inline-block;
  width: 100vw;
  height: 100vh;
  margin-left: -4px;
}

.container>div:first-child {
  margin-left: 0;
}

.container::-webkit-scrollbar {
  display: none;
}

.container>div:nth-child(even) {
  background: blue;
}
Run Code Online (Sandbox Code Playgroud)
<div class="container">
  <div>scroll left</div>
  <div>lorem</div>
  <div>lorem</div>
  <div>lorem</div>
  <div>lorem</div>
  <div>lorem</div>
  <div>lorem</div>
  <div>lorem</div>
  <div>lorem</div>
  <div>lorem</div>
  <div>lorem</div>
  <div>lorem</div>
</div>
Run Code Online (Sandbox Code Playgroud)

html javascript css

0
推荐指数
1
解决办法
6053
查看次数