小编Nit*_*hin的帖子

如何使用Angular 2检测用户不活动?

我正在尝试创建一个Angular应用程序,其中包含用户需要在几分钟不活动后注销的视频.

  • 如果用户正常或全屏观看视频,则无需注销.

  • 如果选项卡处于非活动状态且视频正在播放,我需要在不活动后将其注销.

javascript browser angular

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

为什么“位置:粘性”不适用于 Core UI 的 Bootstrap CSS

我正在尝试使用此处Core UI's找到的反应模板构建反应仪表板。

CSS

.top-stick {
    position: sticky !important;
    position: -webkit-sticky;
    top: 5rem;
    overflow-y: auto;
    height: calc(100vh - 5rem);
}
Run Code Online (Sandbox Code Playgroud)

JSX

<div className="animated fadeIn">
  <Row className="app-scrollable-body">
    <Col xs="12" sm="4" md="3" className="top-stick">
      <Card className="toic">
        <CardBody>
          Lorem ipsum dolor sit amet
        </CardBody>
      </Card>
    </Col>
    <Col xs="12" sm="8" md="9">
      <Card>
        <CardHeader>Card title</CardHeader>
        <CardBody>
        Lorem ipsum dolor sit amet
        </CardBody>
      </Card>
    </Col>
  </Row>
  <div className="app-fixed-footer">
    <span>
      <a href="https://coreui.io">CoreUI</a> &copy; 2018
      creativeLabs.
    </span>
    <span className="ml-auto">
      Powered by{" "}
      <a href="https://coreui.io/react">CoreUI for React</a>
    </span> …
Run Code Online (Sandbox Code Playgroud)

html css sticky jsx core-ui

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

Create React App 抛出“Loading chunk # failed”错误

我正在构建一个CRA Appusingnpm run build然后当我尝试部署它或使用时serve build/我收到以下错误。

Error: "Loading chunk 1 failed.
(error: http://localhost:5000/admin/static/js/1.d30b6723.chunk.js)"

react-dom.production.min.js:4406
Unhandled promise rejection Error: "Loading chunk 1 failed.
(error: http://localhost:5000/admin/static/js/1.d30b6723.chunk.js)"

es6.promise.js:145
Run Code Online (Sandbox Code Playgroud)

新来的反应,我该如何解决这个问题?用Core UI我的模板。

控制台中的网络给出 404。

reactjs webpack create-react-app

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

AJAX 错误:“内容类型中没有多部分边界参数”

我正在尝试将文件从本地主机上传到服务器,但在我的网络控制台中出现以下错误,状态代码为 500:

Content-Type 中没有多部分边界参数

我已经启用cors了我的 nginx 反向代理。我的 AJAX 请求是这样的:

var files = document.getElementById('candidatePhoto').files;
if (!files.length) {
  return alert('Please choose a file to upload first.');
}
var file = files[0];

var form = new FormData();
form.append("files", file);

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "http://example.com",
  "method": "POST",
  "headers": {
    "Content-Type": "multipart/form-data"
  },
  "processData": false,
  "contentType": false,
  "data": form,
  success: function(data) {
    console.log("Success", data);
    addPhoto(data);
  },
  error: function(err) {
    console.log("Error", err);
    alert("Error: " + err);
  }
}
Run Code Online (Sandbox Code Playgroud)

我的 …

javascript ajax jquery

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

在Angular中使用可见性API?

我已经在类似于此的Angular组件的构造函数中实现了Visibility API

constructor() {
    var hidden, state, visibilityChange;
    if (typeof document.hidden !== "undefined") {
        hidden = "hidden";
        visibilityChange = "visibilitychange";
        state = "visibilityState";
    }

    document.addEventListener(visibilityChange, function() {
        if(status == hidden){
            console.log("Hidden");
        }
        else if(status != hidden){
            console.log("Visible");
        }
    }, false);
}

pauseVideo(){
    //Video pause code
}
Run Code Online (Sandbox Code Playgroud)

我需要暂停视频,即pauseVideo()在“可见性”更改为“隐藏”时调用该方法,该怎么办?

javascript angularjs

3
推荐指数
2
解决办法
1873
查看次数

Puppeteer 中的整页 PDF

我正在尝试使用整页 PDF puppeteer,我的代码是这样的,但结果是多个页面的高度等于页面的高度。

我如何解决这个问题?TIA。

const puppeteer = require("puppeteer");

function sleep(ms) {
    return new Promise(resolve => {
        setTimeout(resolve, ms);
    });
}

(async () => {
    const browser = await puppeteer.launch({
        headless: true
    });

    const page = await browser.newPage();

    await page.goto("http://localhost:3000/longpage", {
        waitUntil: "networkidle2"
    });

    let height = await page.evaluate(
        () => document.documentElement.offsetHeight
    );

    console.log("Height", height);

    await page.pdf({
        path: "hni.pdf",
        printBackground: true,
        margin: "none",
        height: height + "px"
    });

    await browser.close();
})();
Run Code Online (Sandbox Code Playgroud)

javascript pdf node.js puppeteer

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

是否在OpenCV中保存灰度视频?

我正在尝试将视频另存为.avi格式,但是我不断收到错误消息"could not demultiplex stream"。我主要想保存灰度视频。

有什么codec我需要使用的吗?

现在我尝试了 XVID, DIVX

import imutils
import cv2
import numpy as np

interval = 30
outfilename = 'output.avi'
threshold=100.
fps = 10

cap = cv2.VideoCapture("video.mp4")

ret, frame = cap.read()
height, width, nchannels = frame.shape

fourcc = cv2.cv.CV_FOURCC(*'DIVX')
out = cv2.VideoWriter( outfilename,fourcc, fps, (width,height))

ret, frame = cap.read()
frame = imutils.resize(frame, width=500)
frame = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)

while(True):

  frame0 = frame

  ret, frame = cap.read()
  frame = imutils.resize(frame, width=500)
  frame = cv2.cvtColor(frame, …
Run Code Online (Sandbox Code Playgroud)

python opencv

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

MongoDB对象未通过删除。猫鼬

我正在尝试删除MongoDB文档,但没有被删除

我的架构是

const mongoose = require("mongoose");

const InvestorSchema = mongoose.Schema({
    name: {
        type: String,
        index: true,
        required: true
    },
    logoUrl: {
        type: String,
        required: true
    },
    website: {
        type: String,
        index: true,
        unique: true,
        required: true
    }
});

module.exports = mongoose.model("Investor", InvestorSchema);
Run Code Online (Sandbox Code Playgroud)

并且我尝试使用这些文件,但没有一个文件删除了该文件。此外,我还在localhost没有用户和角色的情况下运行。

// Required models
const InvestorModel = require("mongoose").model("Investor");

const deletedInvestor = InvestorModel.remove({ _id });
const deletedInvestor = InvestorModel.deleteOne({ _id });
const deletedInvestor = InvestorModel.findByIdAndRemove(_id);
const deletedInvestor = InvestorModel.findOneAndRemove({_id});
const deletedInvestor = InvestorModel.findByIdAndDelete(_id);
const deletedInvestor = InvestorModel.findOneAndDelete({_id}); …
Run Code Online (Sandbox Code Playgroud)

mongoose mongodb node.js

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