小编Nik*_*ola的帖子

为什么JavaFX不包含在Ubuntu Wily(15.10)的OpenJDK 8中?

我今天已经下载了OpenJDK 8 sudo apt-get install openjdk-8-jdk,似乎JavaFX不包含在其中.

> java -version
openjdk version "1.8.0_66-internal"
OpenJDK Runtime Environment (build 1.8.0_66-internal-b17)
OpenJDK Server VM (build 25.66-b17, mixed mode)
Run Code Online (Sandbox Code Playgroud)

我也在最新的Eclipse(Eclipse Mars)中安装了E(fx)clipse,但我仍然得到消息javafx无法解析.

java eclipse ubuntu javafx

81
推荐指数
2
解决办法
10万
查看次数

无法在卸载的组件上调用setState(或forceUpdate)

我试图在组件更新后从服务器获取数据,但我无法做到这一点.据我所知componentWillUnmount,当组件即将被销毁时被调用,但我永远不需要销毁它因此对我来说没用.这会是什么解决方案?什么时候我应该设置状态?

async componentDidUpdate(prevProps, prevState) {
  if (this.props.subject.length && prevProps.subject !== this.props.subject) {
    let result = await this.getGrades({
      student: this.props.id,
      subject: this.props.subject
    });
    this.setState({
      subject: this.props.subject,
      grades: result
    });
  }
}

async getGrades(params) {
  let response, body;

  if (params['subject'].length) {
    response = await fetch(apiRequestString.gradesBySubject(params));
    body = await response.json();
  } else {
    response = await fetch(apiRequestString.grades(params));
    body = await response.json();
  }

  if (response.status !== 200) throw Error(body.message);

  return body;
}
Run Code Online (Sandbox Code Playgroud)

完整错误:

Warning: Can't call setState (or forceUpdate) on an unmounted …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-lifecycle

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

是否可以在GitHub存储库上定义自己的语法?

我正在写一个小型DSL,我很好奇是否有可能以某种方式在存储库源上方的语言栏中显示它,其中所有语言按使用百分比列出或GitHub管理需要允许该语言?

例如,我正在使用名为Puppy的DSL编写一个Ruby项目,并且我希望显示所有具有.puppy扩展名的文件在其他语言旁边的百分比.

git dsl github github-linguist

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

Firefox附加组件的内容脚本不会写入IndexedDB

我正在开发Firefox附加组件,它有一些内容脚本可以将数据保存到IndexedDB.相同的代码在Chrome扩展程序中完美运行,但在Firefox扩展程序中则不行.在Firefox上,一切正常,直到必须将数据写入数据库的部分.

index.js

var data = require("sdk/self").data;
var pageMod = require("sdk/page-mod");
var { indexedDB } = require('sdk/indexed-db');

var request = indexedDB.open("myDatabase");

request.onerror = function(event) {
    console.log("Failure.");
};

request.onsuccess = function(event) {
    console.log("Success.");
};

pageMod.PageMod({
    include: "*",
    contentScriptWhen: "start",
        //contentScriptFile: ["./js/jquery.min.js", "./js/jquery-ui.min.js", "./js/Dexie.min.js", "./js/content-script.js"]
    contentScriptFile: [data.url("js/jquery.min.js"), data.url("js/content-script.js"), data.url("js/jquery-ui.min.js"), data.url("js/Dexie.min.js")],
    contentStyleFile: [data.url("css/jquery-ui.min.css")]
});
Run Code Online (Sandbox Code Playgroud)

content-script.js // 它在Firefox中不起作用的部分

function transition(location, time, date) {

    var db = new Dexie("myDatabase");
    db.version(1).stores({
        likes: 'url, date, time' 
    });

    db.open();

    db.likes.add({url: location, date: date, time: time}).then (function(){

        alert("Informations are added."); …
Run Code Online (Sandbox Code Playgroud)

javascript firefox firefox-addon indexeddb dexie

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

使用Angular进行Steam身份验证

我正在尝试从Angular的主页中使用Steam进行身份验证,但每当我点击按钮(其中有(click)事件指向login()函数AppComponent)时,不会被重定向到Steam页面,而是刷新当前页面并且没有任何反应.

这是服务器端代码:

'use strict';

const express = require('express');
const app = express();
const server = require('http').createServer(app);
const io = require('socket.io').listen(server);
const jwt = require('express-jwt');
const cors = require('cors');
const passport = require('passport');
const SteamStrategy = require('passport-steam').Strategy;
const mongoose = require('mongoose');

app.use(cors());
mongoose.connect('mongodb://localhost:27017/database_test');

passport.serializeUser((user, done) => {
    done(null, user);
});

passport.deserializeUser((obj, done) => {
    done(null, obj);
});

passport.use(new SteamStrategy({
        returnURL: 'http://localhost:3000/auth/steam/return',
        realm: 'http://localhost:3000',
        apiKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
    }, 
    (identifier, profile, done) => {
        process.nextTick(() => {
            profile.identifier …
Run Code Online (Sandbox Code Playgroud)

authentication steam-web-api passport.js angular

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

在 Nest.js 中定义 Node 环境

我正在设置 Nest.js 项目,我正在寻找定义ConfigService用于加载环境变量的Node 环境的有效解决方案:

import { Module } from '@nestjs/common';
import { ConfigService } from './config.service';

@Module({
    providers: [
        {
            provide: ConfigService,
            useValue: new ConfigService(`environments/${process.env.NODE_ENV}.env`)
        }
    ],
    exports: [ConfigService]
})
export class ConfigModule {}
Run Code Online (Sandbox Code Playgroud)

现在我直接在 npm 脚本中定义它(例如"start:dev": "NODE_ENV=development nodemon"),但我想知道是否有更好的方法来处理不同的环境而不是将它附加到每个脚本中?

javascript environment-variables node.js typescript nestjs

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

Rust中不满足特征限制

我正在尝试在Rust中编写一个Tic Tac Toe游戏,但是这个用于更改字段的功能不起作用,我不知道它有什么问题:

fn change_field(mut table: [char; 9], field: i32, player: char) -> bool {
    if field > 0 && field < 10 {
        if table[field - 1] == ' ' {
            table[field - 1] = player;
            return true;
        } else {
            println!("That field isn't empty!");
        }
    } else {
        println!("That field doesn't exist!");
    }

    return false;
}
Run Code Online (Sandbox Code Playgroud)

我收到这些错误:

src/main.rs:16:12: 16:26 error: the trait bound `[char]: std::ops::Index<i32>` is not satisfied [E0277]
src/main.rs:16         if table[field-1] == ' ' {
                          ^~~~~~~~~~~~~~
src/main.rs:16:12: …
Run Code Online (Sandbox Code Playgroud)

rust

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

Nest.js 中特定路由上的 WebSockets

我想创建特定的 API 路由,该路由将仅用于 WebSocket ( /api/events) 但在 Nest.js 上实现 WebSockets 的所有示例中,我偶然发现模块被导入AppModule并且客户端正在向根 URL 发出事件,我不能这样做是因为我有这个中间件;

前端.middleware.ts

import { Request, Response } from 'express';
import { AppModule } from '../../app.module';

export function FrontendMiddleware(
  req: Request,
  res: Response,
  next: Function,
) {
  const { baseUrl } = req;
  if (baseUrl.indexOf('/api') === 0) {
    next();
  } else {
    res.sendFile('index.html', { root: AppModule.getStaticAssetsRootPath() });
  }
}
Run Code Online (Sandbox Code Playgroud)

这是EventGatewayEventModule

event.gateway.ts

import {
  SubscribeMessage,
  WebSocketGateway,
  WebSocketServer,
  WsResponse,
} from '@nestjs/websockets';
import { …
Run Code Online (Sandbox Code Playgroud)

controller websocket nestjs

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

定义向量的函数在Haskell中不起作用

我是Haskell的初学者(目前正在学习模式匹配),我尝试编写简单的函数来定义向量:

vector :: (Num a) => a -> a -> String
vector 0 0 = "This vector has 0 magnitude."
vector x y = "This vector has a magnitude of " ++ show(sqrt(x^2 + y^2)) ++ "."
Run Code Online (Sandbox Code Playgroud)

但是我得到了许多我根本不理解的错误.

helloworld.hs:9:8: error:
    • Could not deduce (Eq a) arising from the literal ‘0’
      from the context: Num a
        bound by the type signature for:
                   vector :: Num a => a -> a -> String
        at helloworld.hs:8:1-37
      Possible fix:
        add (Eq a) to …
Run Code Online (Sandbox Code Playgroud)

haskell function

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

为什么这个JavaScript代码不起作用?

我有for循环,它通过参数遍历数组.当下一个参数是"?","&"或"||"时,它不应该添加逗号,但它总是添加.我无法理解为什么,这里是代码:

var args = ["arg1","arg2","?","arg3"];
var query = "";
for (var i = 0; i < args.length; i++) {

		switch (args[i]) {

			case "?":
				query += " where ";
				break;

			case "&":
				query += " and ";
				break;

			case "||":
				query += " or ";
				break;

			default:
				if (args[i+1] != "?"); 
				{
					query += args[i] + ", ";
					break;
				}
				query += args[i] + " ";
				break;

		}

	}
document.write(query);
Run Code Online (Sandbox Code Playgroud)

当我输入它时(这被""拆分并发送到数组args):

arg1 arg2 ? arg3
Run Code Online (Sandbox Code Playgroud)

它打印出来像这样:

arg1, arg2, where arg3, …
Run Code Online (Sandbox Code Playgroud)

javascript

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