小编use*_*480的帖子

错误:在c ++中返回之前预期的unqualified-id

当我想编译时我得到:Probléme:在"return"返回0之前预期的unqualified-id; 关于最后一行:erreur:在{token.之前的exxted声明

我把代码保持不变只是我改变的中间部分...问题是什么?这是我的代码:


#include <iostream>
using namespace std;

int main()
{
  cout << "Pensez a un personnage : Mlle Rose, le Professeur Violet, "
       << "le Colonel Moutarde," << endl
       << "le Reverend Olive ou Mme Leblanc." << endl << endl;

  cout << "Votre personnage a-t-il des moustaches (1 : oui, 0 : non) ? ";
  bool moustaches;
  cin >> moustaches;

  cout << "Votre personnage porte-t-il des lunettes ? ";
  bool lunettes;
  cin >> lunettes;

  cout << "Votre personnage porte-t-il …
Run Code Online (Sandbox Code Playgroud)

c++

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

React Custom Hooks 全局获取数据并跨组件共享?

在https://reactjs.org/docs/hooks-custom.html 的这个反应示例中,自定义钩子用于 2 个不同的组件来获取用户的在线状态......

function useFriendStatus(friendID) {
  const [isOnline, setIsOnline] = useState(null);

  useEffect(() => {
    function handleStatusChange(status) {
      setIsOnline(status.isOnline);
    }

    ChatAPI.subscribeToFriendStatus(friendID, handleStatusChange);
    return () => {
      ChatAPI.unsubscribeFromFriendStatus(friendID, handleStatusChange);
    };
  });

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

然后它在下面的两个函数中使用:

function FriendStatus(props) {
  const isOnline = useFriendStatus(props.friend.id);

  if (isOnline === null) {
    return 'Loading...';
  }
  return isOnline ? 'Online' : 'Offline';
}

function FriendListItem(props) {
  const isOnline = useFriendStatus(props.friend.id);

  return (
    <li style={{ color: isOnline ? 'green' : 'black' }}>
      {props.friend.name}
    </li>
  );
} …
Run Code Online (Sandbox Code Playgroud)

global fetch reactjs react-hooks

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

Node / Express,如何将 bodyParser 配置为仅在某些路由上使用 raw

我不太确定我是否正确地接近这个,但我的问题是,我通常在我的 API 端点接收 json 数据,然后我从 json req.body 数据创建一个模型实例......我正在使用平均堆栈..

我现在遇到的问题是,我的模型的字段之一是具有 18 个位置的猫鼬长数据类型。但是,bodyParser 会解析数字并将数字的 las 3 个位置四舍五入。我将它用于 _id 字段,因此出现重复的键错误。

我通过 Python 手动构建和发送数据进行测试,并使用 _ast_lib_eval(document) 从我构建的 json 文档中去除所有字符串引号。因此,以某种方式 json bodyParser 正在获取正文并获取数字但切断(或舍入)数字字段,因为我猜,它本机不支持这么长的数字......我可以为某些路线使用另一个 bodyParser 可能...... . 但我不确定如何配置它。

现在最好的方法是什么?我是否必须使用另一个解析器,从而将我的数据作为纯文本或原始数据发送给所有 api 端点?那意味着我必须重做一切以使其适合解析器,对吗?通常的格式是json....

或者我可以在从 bodyparser 解析之前以某种方式从 req.body 获取“原始”数据?这将是手动正确获取数字的最佳方法......但我不知道是否有办法做到这一点......

node.js express long-integer

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

Azure DevOps:如何从发布管道中的 PowerShell 脚本构建 Azure 管道中检索构建工件?

我已经发布了一个构建工件,发布到 $(Build.ArtifactStagingDirectory)/drop,工件名称为“some_sidebar”,工件发布位置是 Azure Pipeline。

如果发布任务中只有 PowerShell Skript,如何在发布管道中检索该工件?

这是代码特定部分:

$path = ".\_some_sidebar\drop"
#$path = $(Build.Repository.LocalPath)
$SPFolderName = "Style Library/_some_sidebar";

# Upload template list
$status = "Uploading template list to Location: " + $SPFolderName
Write-Host $status
$te = Add-PnPFile -Path $path"\some_sidebar.js" -Folder $SPFolderName -Checkout
Set-PnPFileCheckedIn -Url $te.ServerRelativeUrl
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

 Uploading template list to Location: Style Library/_some_sidebar
2020-01-16T09:51:20.5062033Z Add-PnPFile : Local file was not found.
2020-01-16T09:51:20.5062546Z At D:\_work\_temp\6d682160-e8a7-4c56-ab30-7ff8c40f2958.ps1:51 char:7
2020-01-16T09:51:20.5062832Z + $te = Add-PnPFile -Path $path"\some_sidebar.js" -Folder $SPFolderName  ...
Run Code Online (Sandbox Code Playgroud)

我假设 azure 管道中的构建工件路径是虚拟机中的某个路径...但我不知道如何在 shell 脚本内指定该路径,或者该路径是什么...?

powershell release azure artifact azure-pipelines

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

C++错误:只能为对象和函数struct指定存储类

我收到错误消息:错误:只能为我的头文件中的对象和函数结构指定存储类。

/*
 * stud.h
 *
 *  Created on: 12.11.2013
 *      Author: 
 */

//stud.h: Definition der Datenstruktur Stud
#ifndef _STUD_H
#define _STUD_H


struct Stud{
        long matrnr;
        char vorname[30];
        char name[30];
        char datum[30];
        float note;
    };

extern Stud mystud[];

int einlesen (struct Stud[]);
void bubbleSort(struct Stud[] , int );
void ausgeben(struct Stud[], int);

#endif
Run Code Online (Sandbox Code Playgroud)

哪里有问题?

c++

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

我可以在没有Babel的情况下在Node.js中使用ES6 Javascript吗?

我只是想知道,是否有可能在2019年的Node 10.15中使用ES6,因为我认为ES6现在将是本机支持和实现的Javascript功能?我在这里找到了一些答案:NodeJS计划支持导入/导出es6(es2015)模块, 但是我不确定现在的实际状态。

我刚刚在Node中尝试了一些带有箭头功能的ES6类:

 class Test {
     testVar = 1;
     constructor(x,y) {
        this.counter =0;
        this.x = x;
        this.y = y;
        this.increaseCounter();
        this.testVar +=1;
     }

     getCounter = () => {
        console.log("Counter:", this.counter);
     }

     increaseCounter = () => {
        this.counter += 1;
     }
 }
Run Code Online (Sandbox Code Playgroud)

我收到一个错误:

     getCounter = () => {
                ^

SyntaxError: Unexpected token =
Run Code Online (Sandbox Code Playgroud)

而且,我无法创建对该类全局的类实例变量(每次创建新的类实例时,都将testVar增加1。

我知道那里有一个babel编译器软件包来支持此功能并以某种方式转译代码,但是ES6现在不应该被本地支持吗?

javascript node.js ecmascript-6

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

我可以将 React.js 用于本机移动应用程序吗?

是否可以使用 React.js 开发本机移动应用程序,或者我是否需要为移动应用程序明确使用 React Native?React.js 和 React Native 有什么区别?

difference reactjs react-native

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

Javascript 直接选择 HTML ID 元素,无需“getElementbyID”

我刚刚注意到,在 Chrome 中不再需要选择具有 id 的元素,例如 with getElementById,您可以直接使用其名称调用该元素id...例如"para1"在此示例中:

<head>
  <title>getElementById Beispiel</title>
  <script>
    function changeColor(newColor) {
      para1.style.color = newColor;
    }
  </script>
</head>

<body>
  <p id="para1">Irgendein Text</p>
  <button onclick="changeColor('blue');">Blau</button>
  <button onclick="changeColor('red');">Rot</button>
</body>
Run Code Online (Sandbox Code Playgroud)

这方面还有更多规范吗?在互联网上没有找到任何有关它的信息..

html javascript

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

Node.js 无法使用 mongoose 设置默认 UUID

我试图在 mongoose / Node.js / Express 中为我的模式模型中的 _id 字段定义一个默认的 UUID ...

/**Demonstrator
 * 
 */
var mongoose = require('mongoose')
var uuid = require('node-uuid')
require('mongoose-uuid2')(mongoose);
var Schema = mongoose.Schema;
require('mongoose-long')(mongoose);
var Status = require('./Status');
var StatusSchema = Status.Schema; 
var SchemaTypes = mongoose.Schema.Types;
const uuidv4 = require('uuid/v4');
var UUID = mongoose.Types.UUID;

var DemonstratorSchema = new Schema({
    //_id: SchemaTypes.Long;
    _id: { type: String, default: uuidv4()},
    id2: SchemaTypes.Long,
    Test: String,    
})

module.exports = mongoose.model("Demonstrator", DemonstratorSchema);
console.log("DemonstratorSchema created!");
Run Code Online (Sandbox Code Playgroud)

我还试图编写一个自己的函数,如这篇文章: 在 mongoose 中使用 UUIDs for ObjectID 引用 …

uuid mongoose mongodb node.js

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

Docker-compose 使 2 个微服务(前端 + 后端)通过 http 请求相互通信

我有 2 个微服务:带有 next.js 的前端和带有 node.js 的后端,我从前端通过 REST-API 获取数据。

我现在遇到的问题是,我的 2 个服务似乎没有直接相互通信,问题是,当我在开始时使用 getinitialProps() 方法和 fetch-API 获取数据时,它可以工作。我的服务器端前端通过其服务名称找到后端。但是,当我从客户端向后端发出 http 请求时(例如,通过浏览器表单输入)。它再也找不到后端了吗?这是为什么?

这是我的 docker-compose.yml:

version: '3'

services:
  dcbackend:
    container_name: dcbackend
    build:
      context: ./dcbackend
      dockerfile: Dockerfile
    image: dcbackend
    hostname: dcbackend
    ports:
      - '7766:7766'

  dcfrontend:
    container_name: dcfrontend
    build:
      context: ./dcfrontend
      dockerfile: Dockerfile
    image: dcfrontend
    volumes:
      - /app/node_modules
      - ./dcfrontend:/app      
    hostname: dcfrontend
    ports:
      - '6677:6677'
Run Code Online (Sandbox Code Playgroud)

这是我将数据发送到后端的浏览器客户端方法之一(通过浏览器,我的 url 是 http:dcbackend ......所以通常它应该找到后端所在的另一个 docker 环境,但它没有...... .

    if (environment == 'dev') {
  url_link = `http://localhost:${port}`;  
} else {
  url_link = `http://dcbackend:${port}`; …
Run Code Online (Sandbox Code Playgroud)

httprequest node.js docker microservices next.js

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