小编use*_*862的帖子

将字符串转换为数字node.js

我正在尝试将req.params转换为Number,因为这是我在我的架构中为年份参数定义的.

我试过了

req.params.year = parseInt( req.params.year, 10 );  
Run Code Online (Sandbox Code Playgroud)

Number( req.params.year);
Run Code Online (Sandbox Code Playgroud)

1*req.params.year;
Run Code Online (Sandbox Code Playgroud)

但他们没有工作.我需要安装一些东西吗?

string type-conversion node.js

58
推荐指数
2
解决办法
12万
查看次数

javascript中调用对象和函数之间的区别

我正在写两个文件 - 一个是html,一个是JavaScript.所以要调用我做的对象

 document.getElementById("nameObj").onmouseover = changeMe;
Run Code Online (Sandbox Code Playgroud)

在我做的JavaScript文件中

changeMe = function()
{
 //and here i write the function
}
Run Code Online (Sandbox Code Playgroud)

但现在我正在尝试优化我的代码并调用一个包含对象的函数.我创建了部分(其中4个),我正在尝试用onmouseover和更改颜色onmouseout.这是html的代码:

<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" href="style.css">
        <script src="script.js"> </script>
        <title> test 2</title>
    </head>
    <body>
        <header> </header>
        <div id="wrapper">
        <main>
        <section class="mysection" id="section1"> </section>
        <section class="mysection" id="section2"> </section>
        <section class="mysection" id="section3"> </section>
        <section class="mysection" id="section4"> </section>
        </main>
        <div class="clear"> </div>
        </div>
        <footer> </footer>
                <script>
            (function(){
                var sec = document.getElementsByClassName("mysection");
                for(var i=0; i<3; i++)
                {
                    sec[i].onmouseover=changeMe(sec[i], i);
                    sec[i].onmouseout=changeBack(sec[i]); …
Run Code Online (Sandbox Code Playgroud)

html javascript onmouseover onmouseout

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

获取图像节点js的主色

我正在尝试获取计算机上图像的主色。我安装imagemagickdominant-color使用此代码之前。undefined我得到和的结果000000

为什么会发生这种情况?我做错了什么?

var AWS = require('aws-sdk'),
fs = require('fs');
var express = require("express");
var app = express();

const resizeImg = require('resize-img');
var color = require('dominant-color'),
    imgPath = './Users/ADIBAR/Desktop/cloud/beach_life-normal.jpg';

color(imgPath,function(err,color){
    console.log(color);
})

color(imgPath,{format:'rgb'},function(err,color){
    console.log(color);
})

// For dev purposes only
AWS.config.update({ accessKeyId: '', secretAccessKey: '' });

var fileStream = fs.createReadStream('beach_life-normal.jpg');
fileStream.on('error', function (err) {
  if (err) { throw err; }
});  

fileStream.on('open', function () {
  var s3 = new AWS.S3();




resizeImg(fs.readFileSync('beach_life-normal.jpg'), {width: 128, …
Run Code Online (Sandbox Code Playgroud)

javascript image colors amazon-s3 node.js

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

如何在控制台窗口中找到光标的坐标?

我使用以下代码为光标提供了一些坐标:

COORD c = { 7, 7 };
HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(h, c); 
Run Code Online (Sandbox Code Playgroud)

现在,我在屏幕上写一些文本,我想知道光标的当前位置。

我发现的唯一功能是使用POINT而不是COORD。所以我写道:

VOID KeyEventProc(KEY_EVENT_RECORD ker)
{
    POINT position;
    GetCursorPos(&position);

        if (position.y<14 && position.x<9){
            if (ker.bKeyDown)
                printf("%c", ker.uChar);
        }

}
Run Code Online (Sandbox Code Playgroud)

但是POINT并没有提供我需要的相同值。如何转换?或获取电流的功能是什么COORD

c++ windows console winapi

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

如何将字符串转换为int c#

我想将string(w.main.temp)转换为整数.我正在使用以下代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System.Collections;

namespace project1
{

    interface IWeatherDataService
{
       // public WeatherData GetWeatherData(Location location);

}

    public class WeatherData
    {
        public string temp { get; set; }
    }
    public class Location
    {
        public string name { get; set; }
        public string id { get; set; }

        public WeatherData main { get; set; }

    }
    public class WeatherDataServiceException
    {

    }

    class Program
    {
        static …
Run Code Online (Sandbox Code Playgroud)

c# string int type-conversion

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