小编Dav*_*vid的帖子

无法在React中使用FontAwesome在'Node'上执行'removeChild'

每当我尝试className='fa-spin'在React中使用FontAwesome微调器图标(带)时,我收到以下错误:

Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
at removeChild (http://localhost:5000/public/bundle.js:19553:22)
at unmountHostComponents (http://localhost:5000/public/bundle.js:13683:11)
at commitDeletion (http://localhost:5000/public/bundle.js:13727:5)
at commitAllHostEffects (http://localhost:5000/public/bundle.js:14419:13)
at HTMLUnknownElement.callCallback (http://localhost:5000/public/bundle.js:5035:14)
at Object.invokeGuardedCallbackDev (http://localhost:5000/public/bundle.js:5074:16)
at invokeGuardedCallback (http://localhost:5000/public/bundle.js:4931:27)
at commitRoot (http://localhost:5000/public/bundle.js:14508:9)
at performWorkOnRoot (http://localhost:5000/public/bundle.js:15510:42)
at performWork (http://localhost:5000/public/bundle.js:15460:7)
Run Code Online (Sandbox Code Playgroud)

编辑:现在问题出现了几次,代码本身并没有什么特别之处.我一直在使用微调器作为加载图标,每当微调器被内容替换时就会发生错误.例:

return (
  <div>
    {this.state.loading === true ? <i className="fa-spin fas fa-sync"></i> : (
      this.state.recipes.length === 0 ? (
        <div className='text-center'>
          <h2>There doesn't seem to be …
Run Code Online (Sandbox Code Playgroud)

font-awesome reactjs

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

POST未选中复选框,其值为Node

这是一个常见的主题,但在这个特定的用例中,我一直无法找到解决方案.我在一个表单中有一个动态数量的复选框,正在提交给Node.js服务器.我的复选框看起来像这样:

<input type='hidden' name='ingredient[num]' value='off' /> //not currently in use, see below
<input type='checkbox' name='ingredient[num]' checked />
Run Code Online (Sandbox Code Playgroud)

选中所有复选框后,服务器会收到类似这样的内容(在req.body.ingredient之后):

{ num: ['on','on','on'] }
Run Code Online (Sandbox Code Playgroud)

当取消选中某些或所有复选框时,我希望它接收具有相同数量值的类似内容:

{num: ['on','off','off'] }
Run Code Online (Sandbox Code Playgroud)

我尝试在我的复选框之前和之后使用值='off'的隐藏输入,但这没有用.选中时,服务器会同时接收"开"和"关"值.我也尝试了一种JavaScript解决方法(下面),我还没有让它工作.有任何想法吗?

<script>
let form = document.getElementById('addIngredients');
form.addEventListener('submit', function(e) {
    e.preventDefault();

    let boxes = document.querySelectorAll('input[type=checkbox]:not(:checked)');
    boxes.forEach(function(box) {
        box.setAttribute('value', 'off');
    });

    form.submit();
})
</script>
Run Code Online (Sandbox Code Playgroud)

编辑:这不是建议的重复问题.使用隐藏输入时,正文解析器似乎不会将复选框分组为数组.例如,有三个盒子,都经过检查,服务器正在接收[ 'off', 'on', 'off', 'on', 'off', 'on' ]

javascript forms checkbox node.js

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

节点中 Stripe Webhook 出现 404 错误

我为 webhook 设置了以下代码:

var express = require('express');
var router = express.Router();
var nodemailer = require('nodemailer');
var middleware = require('../middleware');
var stripe = require("stripe")(process.env.SECRET_KEY);

// router.use(require("body-parser").raw({type: "*/*"}));

router.post("/webhook/all", function(req, res) {
  // Retrieve the request's body and parse it as JSON
  // var event_json = JSON.parse(req.body);
  middleware.sendEmail('Webhook Test', 'event_json');
  res.sendStatus(200);
});

module.exports = router;
Run Code Online (Sandbox Code Playgroud)

当我使用localhostPostman 测试它时,它可以工作,但是当它运行时,它会响应 404 错误:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot POST /webhook/all</pre>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

我唯一的猜测是它与我有关HTTPS,因为Stripe 文档是这样说的: …

https webhooks node.js stripe-payments stripe.js

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

猫鼬find()无法与$ not查询一起使用

这是我的查找请求:

Recipe.find({'author.id': {$not: {user}}}
Run Code Online (Sandbox Code Playgroud)

这是文档:https : //docs.mongodb.com/manual/reference/operator/query/not/index.html

这是错误:

Error: Can't use $not with ObjectId.
Run Code Online (Sandbox Code Playgroud)

我想查找当前用户未编写的所有食谱。参数工作正常,所以这不是问题。一定有办法做到这一点,否则我做错了吗?

javascript mongoose mongodb node.js express

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