小编Cri*_*alu的帖子

使用 redux 中间件控制 React-router 导航

在 Redux 中间件功能的帮助下,当离开播放页面时,我会显示警告模式。

问题是我现在无法控制导航。在模式显示之前页面已更改。

有什么方法可以阻止路由器导航并根据模式选择做出决定吗?

在此输入图像描述

middleware.push(routeIntrerceptor);

.....

const routeIntrerceptor = ({dispatch, getState}) => next => action => {
  const state = getState();
  const location = state.router.location.pathname;

  if (action.type === '@@router/LOCATION_CHANGE' && location.includes('play')) {
    dispatch({ type: 'SET_DIALOG_TOGGLE' });
  }
  next(action);
};

export default routeIntrerceptor;
Run Code Online (Sandbox Code Playgroud)

middleware reactjs redux react-router-v4

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

如何让 VSCode 与 React 语法完美配合?

我安装了所有推荐的扩展,但 VSCode 仍然无法识别任何 React 语法。

我必须做什么才能使VSCodeReact (js / jsx) 语法很好地配合?

在此输入图像描述

reactjs visual-studio-code

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

获取根据另一个数组的内容排序的数组

我如何对allGames数组进行排序,使其首先具有installGames

const allGames = [
    { id: 2, name: 'game2' },
    { id: 1, name: 'game1' },
    { id: 4, name: 'game4' },
    { id: 3, name: 'game3' },
]
const installedGames = [
    { id: 2, name: 'game2' },
    { id: 3, name: 'game3' }
]

const sorted = allGames.sort((a, b) => {
    return a.id - b.id // but this just sorts by id
});
Run Code Online (Sandbox Code Playgroud)

基本上我想得到这个命令:

{ id: 2, name: 'game2' },
{ id: 3, name: …
Run Code Online (Sandbox Code Playgroud)

javascript arrays sorting

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

为什么 ClickOnce 停止发布 Setup.exe?

在此输入图像描述

看来如果我删除 setup.exe,VisualStudio/ClickOnce 将永远不会再创建它。

我重建、清理解决方案、更新程序集版本和文件版本、删除证书、创建新证书。我不知道还能做什么。

如何让 VisualStudio/ClickOnce 再次发布 setup.exe?

clickonce visual-studio visual-studio-2015

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

电子如何允许不安全的https

加载https://github.com对于exmaple来说效果很好。
但是加载不安全的https时,页面显示为空

我做了一些研究,并尝试了3个标志(webSecurityallowDisplayingInsecureContentallowRunningInsecureContent没有成功下文)。

寻找任何已知的解决方案。谢谢。

const { BrowserWindow } = require('electron').remote;

    let win = new BrowserWindow({
        width: 800,
        height: 600,
        webPreferences: {
            plugins: true,
            nodeIntegration: false,
            webSecurity: false,
            allowDisplayingInsecureContent: true,
            allowRunningInsecureContent: true
        }
    });

    win.loadURL('https://insecure...')
Run Code Online (Sandbox Code Playgroud)

electron

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

Angular2 CanActivate从beta到当前的RC3

我正在尝试在Angular2中实现此视频中的Auth0登录方法.他也在使用angular2-jwt.

我阅读了文档,试图实现它,但我无法做到正确.
我试过export class NavbarComponent implements CanActivate, routerCanActivate(){},canActivate(){}.我被卡住了.

CanActivate需要对 当前RC3 进行哪些更改?

import {CanActivate} from 'angular2/router';
import {tokenNotExpired, JwtHelper} from 'angular2-jwt'; 
...    
@CanActivate (()=>tokenNotExpired())
export class NavbarComponent{
...
}
Run Code Online (Sandbox Code Playgroud)

angular

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

猫鼬从对象中删除属性

寻找一种在将对象属性发送到前端之前删除对象属性的方法。
这有什么原因吗:

var obj = {
    name: 'cris',
    age: 22,
}
console.log(obj) //output name, age
delete obj.name
console.log(obj) //output age
Run Code Online (Sandbox Code Playgroud)

这不是:

User.findOne({ username: req.query.username }, function (err, user) {
    if (user != null) {
        console.log(user) //output all props
        delete user.salt || delete user['salt']
        console.log(user) //output all props
    } 
});
Run Code Online (Sandbox Code Playgroud)

javascript json mongoose

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

React-intl cosnt <FormattedMessage />给出[object object]作为结果

我正在使用"react-intl":"^ 2.4.0"和"react":"^ 16.2.0".

我试图将FormattedMessage标记的输出分配给常量并将其放在输入标记占位符中.

代码图片

预期输出输入字段,其中包含相应语言的文本,但它在文本框内出现[对象对象].

reactjs react-intl

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

删除所有 node_modules 子文件夹

我正在进行硬盘升级,在尝试备份我的 NodeJS 项目时,我意识到所有node_modules子文件夹都有超过 100 万个文件。

所以我正在寻找一种方法来删除所有node_modules子文件夹及其所有内容。

这些项目位于:

C:/Node/App1/node_modules/..
C:/Node/App2/node_modules/..
C:/Node/App3/node_modules/..
etc..
Run Code Online (Sandbox Code Playgroud)

我的操作系统是 Windows 10,但我可以尝试 Windows 或 Linux 命令,因为我使用的是cmder,并且它接受两种类型的命令。

linux windows cmder

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

Angular订单的React方法是什么

从Angular 进行orderBy过滤的React方法是什么 ?

在此示例中,您如何按年龄订购动物?

密码笔

class Application extends React.Component {
  constructor(props){
    super(props);
    this.state={
      animals: [
        {id: 1, age: 5, type: "cat"}, 
        {id: 2, age: 3, type: "dog"},
        {id: 3, age: 10, type: "wolf"}
      ]
    }
  }
  render() {
    let {animals} = this.state;

    return (
      <div>
        {animals.map((animal)=>{
          return (<p key={animal.id}>{animal.type}</p>)
        })}
      </div>
    )
  }
}
Run Code Online (Sandbox Code Playgroud)

reactjs

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

渲染价格或基于2个阵列拥有

我有2个数组:all_gamesowned_games.
我希望显示所有游戏,并在每个游戏旁边:
- 如果它是owned显示所有
- 如果它not owned显示价格

电流输出:
1 - 10.00
2 - 10.00
3 - 10.00

DesiredOutput:
1 - 拥有
2 - 拥有
3 - 10.00

CODEPEN

render() {
    let renderPriceSection
    let renderOwned = <span>Owned</span>
    let renderPrice = <span>10.00</span>
    let all_games = [{ "game_id": 1 }, { "game_id": 2 }, { "game_id": 3 }]
    let owned_games = [{ "game_id": 1 }, { "game_id": 2 }]

    all_games.map((game) => {
        owned_games.map((owned_game) => { …
Run Code Online (Sandbox Code Playgroud)

javascript arrays reactjs

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

从前端传递数据以创建动态multer目标文件夹

我如何uploadYear将 Angular 服务传递到 Multer 目的地以获得动态路径,例如“./public/uploads/”+uploadedYear?

multer 的工作方式对我来说似乎很扭曲,我无法弄清楚在哪里存储额外的对象,以便它可以一直到达 Multer 目的地。

基本上我看不到myfile从前端到后端的路径,或者我如何在后端访问它。

角度服务

    this.uploadCV = function (file, uploadYear) {
        console.log(uploadYear)  //output 2017
        var fd = new FormData()
        fd.append('myfile', file.upload)
        return $http.post('/api/uploadCV', fd, {
            transformRequest: angular.identity,
            headers: { 'Content-Type': undefined }
        })
    }
Run Code Online (Sandbox Code Playgroud)

应用程序接口

var cv = ''
var CVstorage = multer.diskStorage({
    destination: function (req, file, cb) {
        cb(null, './public/uploads')
    },
    filename: function (req, file, cb) {
        if (!file.originalname.match(/\.(jpg)$/)) {
            var err = new Error()
            err.code = 'filetype'
            return …
Run Code Online (Sandbox Code Playgroud)

javascript multipartform-data node.js angularjs multer

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