小编Dhi*_*bbi的帖子

从材料 ui 处理自动完成组件的更改

我想将Autocomplete组件用于输入标签。我正在尝试获取标签并将它们保存在状态中,以便稍后将它们保存在数据库中。我在反应中使用函数而不是类。我确实尝试过onChange,但没有得到任何结果。

<div style={{ width: 500 }}>
  <Autocomplete
    multiple
    options={autoComplete}
    filterSelectedOptions
    getOptionLabel={(option) => option.tags}
    renderInput={(params) => (
      <TextField
        className={classes.input}
        {...params}
        variant="outlined"
        placeholder="Favorites"
        margin="normal"
        fullWidth
      />
    )}
  />
</div>;
Run Code Online (Sandbox Code Playgroud)

reactjs material-ui

35
推荐指数
5
解决办法
8万
查看次数

在 Jenkins Pipeline 上解析 JSON (groovy)

我创建了一个方法,如在线所示:

@NonCPS
def parseJsonString(String jsonString) {
    def lazyMap = new JsonSlurper().parseText(jsonString)

    // JsonSlurper returns a non-serializable LazyMap, so copy it into a regular map before returning
    def m = [:]
    m.putAll(lazyMap)
    return m
}
Run Code Online (Sandbox Code Playgroud)

但我收到以下错误:

错误:java.io.NotSerializableException:groovy.json.internal.LazyMap

为了解决这个问题,我必须创建一个完整的方法来执行整个步骤。例如,在一个方法中,我会做与上面相同的操作,解析我想要的信息,最后将其作为字符串返回。

然而,这带来了另一个问题,尤其是如果您将此方法包装在 a 中withCredentials,则需要另一个withCredentials.

groovy json jenkins jsonparser

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

如何在 Bootstrap 5 中将导航项目向右对齐?

我从https://www.codeply.com/go/qhaBrcWp3v复制了导航栏 HTML 代码

示例 6:

<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="d-flex flex-grow-1">
    <span class="w-100 d-lg-none d-block"><!-- hidden spacer to center brand on mobile --></span>
    <a class="navbar-brand d-none d-lg-inline-block" href="#">
        Navbar 6
    </a>
    <a class="navbar-brand-two mx-auto d-lg-none d-inline-block" href="#">
        <img src="//placehold.it/40?text=LOGO" alt="logo">
    </a>
    <div class="w-100 text-right">
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#myNavbar">
            <span class="navbar-toggler-icon"></span>
        </button>
    </div>
</div>
<div class="collapse navbar-collapse flex-grow-1 text-right" id="myNavbar">
    <ul class="navbar-nav ml-auto flex-nowrap">
        <li class="nav-item">
            <a href="#" class="nav-link m-2 menu-item nav-active">Our Solution</a>
        </li>
        <li class="nav-item"> …
Run Code Online (Sandbox Code Playgroud)

css alignment navbar bootstrap-5

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

Jest + MockImplementationOnce + 第二次不起作用

我正在使用 JEST 框架对我的 node.js 项目进行单元测试。我用于mockImplementationOnce模拟第三方库方法,如下所示:

jest.mock('abc', () => {
    return { a: { b: jest.fn() } };
  });
const abcjs= require('abc');

describe("1st test", () => { 
  test("should return true", async () => {
    abcjs.a.b.mockImplementationOnce(() => Promise.resolve(
      return true}
    ));
  });
});

describe("2nd test", () => { 
  test("should return false", async () => {
    abcjs.a.b.mockImplementationOnce(() => Promise.resolve(
      return false}
    ));
  });
});
Run Code Online (Sandbox Code Playgroud)

第一个测试已成功执行,但第二个测试它调用实际方法,它不是模拟。 我尝试重置模拟afterEach,但没有帮助。

unit-testing node.js jestjs

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

获取异常 java.lang.NoClassDefFoundError: 无法初始化类 javax.xml.bind.DatatypeConverterImpl

在实现 Jwt Spring Security 实现时出现以下异常:

java.lang.NoClassDefFoundError: 无法初始化类 javax.xml.bind.DatatypeConverterImpl 。

在 Spring Boot 项目中

pom.xml 中的依赖如下:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <!-- For Working with Json Web Tokens (JWT) -->
    <dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt</artifactId>
        <version>0.9.0</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <!-- marked the embedded servlet container as provided -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.zaxxer</groupId>
        <artifactId>HikariCP</artifactId>
        <version>2.6.0</version>
    </dependency>
    <!-- hot swapping, disable cache for template, enable live reload -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId> …
Run Code Online (Sandbox Code Playgroud)

spring-security jwt

9
推荐指数
3
解决办法
7188
查看次数

使用 Instagram Basic Display API 时出现“无效平台应用”错误

我正在尝试使用 Instagram Basic display API,但是当我发布授权代码以获取访问令牌时,我不断收到以下错误

{“error_type”:“OAuthException”,“code”:400,“error_message”:“平台应用无效”}

我下面的所有步骤这里所说- > https://developers.facebook.com/docs/instagram-basic-display-api/getting-started和是的,我现在用的是Instagram的应用程序ID和它的客户端秘密,那是在Products -> Instagram -> Display和以下是我发送请求的 URL

"https://api.instagram.com/oauth/access_token?client_id=".$app_id."&client_secret=".$app_secret."&grant_type=authorization_code&redirect_uri=".$redirecturi."&code=".$code,

php api facebook-graph-api facebook-apps instagram-graph-api

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

Laravel 7.x 中未找到“Illuminate\Support\Facades\Http”类

在我的 Laravel 应用程序中,作为计划任务,我想在我的自定义类中发出 Http 请求,但我得到

Class 'Illuminate\Support\Facades\Http' not found {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Class 'Illuminate\\Support\\Facades\\Http' not found
Run Code Online (Sandbox Code Playgroud)

这是我的自定义课程

<?php

namespace App\MyModels\GetData;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;

class Test
{
    public function __invoke()
    {
        Log::info("Cron executed : ");
        $response = Http::get("https://google.com");
        Log::info(print_r($response, true));
    }
}
Run Code Online (Sandbox Code Playgroud)

在 Laravel 文档中,它说:

要发出请求,您可以使用 get、post、put、patch 和 delete 方法。首先,我们来看看如何发出基本的 GET 请求:

使用 Illuminate\Support\Facades\Http;

$response = Http::get(' http://test.com ');

httprequest laravel

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

尝试从命名空间“Doctrine\Bundle\DoctrineCacheBundle”加载类“DoctrineCacheBundle”

任何人都可以帮助我吗,伙计们?每次运行命令php bin/console server:run时都会出现此错误:

PHP 致命错误:未捕获的 Symfony\Component\Debug\Exception\ClassNotFoundException:尝试从命名空间“Doctrine\Bundle\DoctrineCacheBundle”加载类“DoctrineCacheBundle”。您是否忘记了另一个命名空间的“use”语句?在 C:\Users\XX-2\Desktop\React Projects\test_project\src\Kernel.php:23

symfony symfony4

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

使用 Axios 发出 2 个连续请求 - 第二个请求取决于第一个请求的响应

以下代码else在解析之前不等待部件返回数据。

这段代码我哪里出错了?

return request.get(`${<URL1>}`)
.then((res) => {
    if (res1.data[0]) {
        data1 = res.data[0]};
    } else {
        request.get(`${<URL2>`)
            .then((res2) => {
                data1 = res2.data
            });
    }
    return Promise.resolve(data1);
})
Run Code Online (Sandbox Code Playgroud)

提前致谢。

javascript reactjs axios

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

为什么我部署的 Symfony 应用程序无法加载 bundles.php 文件?

我有一个 Symfony Web 应用程序。我想将其部署到虚拟专用服务器。

我在Laravel Homestead Vagrant box中开发了该应用程序,并通过 Github 操作进行部署。

在我的本地计算机上,该应用程序在 Vagrant 环境中运行良好,但在将文件同步到实时服务器后,它给我一个错误屏幕。

警告:require(/var/www/thebedechkacase.com/src/config/bundles.php):无法打开流:没有这样的文件或目录

错误来自 Kernel.php 的第 20 行,如下所示

const CONFIG_EXTS = '.{php,xml,yaml,yml}';
public function registerBundles()
{
    $contents = require $this->getProjectDir().'/config/bundles.php';
    foreach ($contents as $class => $envs) {
        if ($envs[$this->environment] ?? $envs['all'] ?? false) {
            yield new $class();
        }
}
Run Code Online (Sandbox Code Playgroud)

我不明白的是,根据错误消息和上面的代码, 的输出解析$this->getProjectDir()/var/www/thebedechkacase.com/src/thebedechkacase.com是存储我的应用程序代码的文件夹),但bundles.php实际上位于/var/www/thebedechkacase.com/config/.

为什么 Symfony 认为 theprojectDir存在并且为什么不在根目录(又名 )中src查找?为什么这在我的开发环境中有效,但在实时服务器上却不起作用?configthebedechkacase.com/

附加信息:我正在尝试使用在 Github 操作中调用的 shell …

php deployment symfony devops

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