小编ggo*_*len的帖子

如何更改vite应用端口

如果您要更改vite应用程序端口,请按照流程操作。

"scripts": {
  "dev": "vite --port 3006",
  "build": "vite build",
  "preview": "vite preview"
}
Run Code Online (Sandbox Code Playgroud)

port reactjs vite

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

Vite:无法解析入口模块(index.html)

我是 Openshift 3.11 部署的新手,我为 React 应用程序创建了一个多阶段 Dockerfile,构建希望在我的本地计算机上正确运行,但是当我在 openshift 集群上运行时,出现以下错误:

\n
> kncare-ui@0.1.0 build\n> tsc && vite build\n\nvite v2.9.9 building for production...\n\xe2\x9c\x93 0 modules transformed.\nCould not resolve entry module (index.html).\nerror during build:\nError: Could not resolve entry module (index.html).\n    at error (/app/node_modules/rollup/dist/shared/rollup.js:198:30)\n    at ModuleLoader.loadEntryModule (/app/node_modules/rollup/dist/shared/rollup.js:22680:20)\n    at async Promise.all (index 0)\nerror: build error: running \'npm run build\' failed with exit code 1\n
Run Code Online (Sandbox Code Playgroud)\n

这是我的文档

\n
FROM node:16.14.2-alpine as build-stage      \nRUN mkdir -p /app/\nWORKDIR /app/\nRUN chmod -R 777 /app/\nCOPY package*.json /app/\nCOPY tsconfig.json /app/\nCOPY tsconfig.node.json …
Run Code Online (Sandbox Code Playgroud)

node.js openshift docker dockerfile

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

Puppeteer 错误:必须为“puppeteer-core”指定“executablePath”或“channel”

我正在尝试制作一个简单的 Puppeteer 项目。我当前的代码只是一个测试。但这不起作用。

import bypass from './captcha/captchaBypasser.js';
import {createRequire} from "module";

const require = createRequire(import.meta.url);

const puppeteer = require('puppeteer-extra');
const hidden = require('puppeteer-extra-plugin-stealth')

test()

async function test() {

  // Launch sequence
  puppeteer.use(hidden())
  const browser = await puppeteer.launch({
    args: ['--no-sandbox',],
    headless: false,
    ignoreHTTPSErrors: true
  })

  const page = await browser.newPage()
  await page.setViewport({
    width: 1920,
    height: 1280,
    deviceScaleFactor: 1,
  });

  //Go to page
  await page.goto('https://google.com/', {
    waitUntil: 'networkidle0',
  });
}
Run Code Online (Sandbox Code Playgroud)

我四处寻找解释,但似乎我是唯一遇到此错误的人

        throw new Error(message);
              ^

Error: An `executablePath` or `channel` must be …
Run Code Online (Sandbox Code Playgroud)

node.js puppeteer

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

为什么我不应该使用 catch() 来处理 React useEffect API 调用中的错误?

在 React 文档的这个页面上:

https://reactjs.org/docs/faq-ajax.html

代码注释说...

注意:在这里处理错误而不是 catch() 块很重要,这样我们就不会吞下来自组件中实际错误的异常。

...关于在第二个参数.then之后处理错误fetch。文档中的完整片段是:

  useEffect(() => {
    fetch("https://api.example.com/items")
      .then(res => res.json())
      .then(
        (result) => {
          setIsLoaded(true);
          setItems(result);
        },
        // Note: it's important to handle errors here
        // instead of a catch() block so that we don't swallow
        // exceptions from actual bugs in components.
        (error) => {
          setIsLoaded(true);
          setError(error);
        }
      )
  }, [])
Run Code Online (Sandbox Code Playgroud)

它没有详细说明这个建议,我已经看到了许多使用 React 代码catch处理 API 调用错误的例子。我试过谷歌搜索,但找不到任何说明。

有人可以更详细地解释一下为什么我不应该catch用来处理fetchuseEffect钩子中进行API 调用时出现的错误吗?

还是在某些情况下可以这样做,而在其他情况下则不然?

“在组件中吞下异常 [...]”是什么意思? …

reactjs react-hooks use-effect

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

Objective C将数字转换为NSNumber

为什么这不喜欢编译器,而铸造应该像在c中一样工作,我可以在这里阅读如何在Objective-C中转换对象

[p setAge:(NSNumber*)10];
Run Code Online (Sandbox Code Playgroud)

哪里

- (NSNumber*) age {
    return _age;
}
- (void) setAge: (NSNumber*)input {
    [_age autorelease];
    _age = [input retain];
}
Run Code Online (Sandbox Code Playgroud)

iphone objective-c

22
推荐指数
5
解决办法
4万
查看次数

为什么拉取请求在变基后会显示额外的提交?

因此,我从一个提前了几次提交的拉取请求开始develop,我们称这个分支为分支feature

feature与开发有 1 处合并冲突。所以我决定重新调整它并解决冲突。

  1. git checkout develop git pull
  2. git checkout feature git pull
  3. git rebase develop
  4. 合并冲突已修复 - 添加了新提交
  5. git rebase --continue
  6. 变基成功。
  7. git push(我实际上使用的是“同步更改”)

经过这些步骤后,GitHub 上的 PR 从 7 次提交增加到 60 多次提交。

我原本预计它只会从 7 到 8 次提交,因为我修复了一个冲突。

知道发生了什么以及如何(如果需要)修复它吗?

如果需要,我可以发布更多信息。

git github rebase pull-request

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

为什么Dijkstra的算法使用堆(优先级队列)?

我尝试在不使用优先级队列(Heap)的情况下在循环加权图上使用Djikstra算法,并且它有效.

然后我搜索谷歌"为什么我们需要一个优先级队列来实现这个?" 作为搜索的结果,我浏览了维基百科,在那里我了解到原始实现不使用优先级队列并在O(| V | 2)中运行,即V平方时间.

现在,如果我们只删除优先级队列并使用正常队列,则运行时间是线性的,即O(V + E).

请有人建议那么为什么我们需要优先队列?

dijkstra priority-queue graph-algorithm

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

Puppeteer - 错误:协议错误 (Network.getResponseBody):找不到具有给定标识符的资源

我正在尝试使用此代码使用 puppeteer 从网站获取响应正文。

#!/usr/bin/env node

require('dotenv').config();
const puppeteer = require('puppeteer');
const readline = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
const path = require('path');
const fs = require('fs');

//
console.log('Starting Puppeteer...');

let responseBody = [];

(async () => {
    const browser = await puppeteer.launch({
        headless: false,
        executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
    });
    const page = await browser.newPage();
    
    await page.setRequestInterception(true);

    page.on('request', (request) => {
        request.continue();
    });

    //
    page.on('requestfinished', async (request) => {
        const response =  await request.response();
        const url = response.url();
        // store …
Run Code Online (Sandbox Code Playgroud)

javascript node.js puppeteer

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

如何更改 ruby​​ 3.0 的 IRB 中的默认语法着色

我很高兴使用最新的 ruby​​ 3.0;以及可以访问更新的命令行解释器,该解释器可以进行语法突出显示和着色。

然而,颜色对我来说有点难看。我怎样才能改变它们?IRB 的命令行选项允许我使用 关闭着色--nocolorize,但我无法弄清楚配置文件在哪里,可以让我更改默认值(例如,使蓝色更亮。)

ruby syntax-highlighting irb ruby-3

13
推荐指数
4
解决办法
3420
查看次数

Why is b[2] false?

string s;
bool b[] = {s=="",  s==s.c_str(),  s.c_str()==""};
Run Code Online (Sandbox Code Playgroud)

sets

b[] = {true, true, false};
Run Code Online (Sandbox Code Playgroud)

why is b[2] false?

If A==B and A==C, should that not imply B==C?

c++ string stdstring string-literals equality-operator

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