小编Hak*_*lek的帖子

如何在反应导航 5.x 中隐藏选项卡导航(底部选项卡)的标题?

我正在尝试使用 createBottomTabNavigator 函数来创建底部导航选项卡,我想隐藏标题,如下所示:

我在 stackNavigator 中有一个 BottomTabNavigator,代码如下:
这是 rooter 配置文件 rooter.js

import React, { Component } from 'react';
import WelcomeScreen from '../component/WelcomeScreen';
import Login from '../component/login/Login';
import Register from '../component/register/Register';
import RegisterTwo from '../component/register/RegisterTwo';
import TabsBottom from '../component/tabs/TabsNavigation'
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';

  const Stack = createStackNavigator();
  const AppSwitchNavigator = () => {
    return (
      <NavigationContainer>
        <Stack.Navigator  initialRouteName="WelcomeScreen">
          <Stack.Screen name="TabsBottom" component={TabsBottom} />
          <Stack.Screen name="WelcomeScreen" component={WelcomeScreen} />
          <Stack.Screen name="Register" component={Register} />
          <Stack.Screen name="RegisterTwo" component={RegisterTwo} …
Run Code Online (Sandbox Code Playgroud)

javascript android reactjs react-native react-redux

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

带有查询字符串的 HttpClient GetAsync

我正在使用 Google 的地理编码 API。我有两种方法,一种有效,另一种无效,我似乎无法弄清楚为什么:

string address = "1400,Copenhagen,DK";
string GoogleMapsAPIurl = "https://maps.googleapis.com/maps/api/geocode/json?address={0}&key={1}";
string GoogleMapsAPIkey = "MYSECRETAPIKEY";
string requestUri = string.Format(GoogleMapsAPIurl, address.Trim(), GoogleMapsAPIkey);

// Works fine                
using (var client = new HttpClient())
{
    using (HttpResponseMessage response = await client.GetAsync(requestUri))
    {
        var responseContent = response.Content.ReadAsStringAsync().Result;
        response.EnsureSuccessStatusCode();
    }
}

// Doesn't work
using (HttpClient client = new HttpClient())
{
    client.BaseAddress = new Uri("https://maps.googleapis.com/maps/api/", UriKind.Absolute);
    client.DefaultRequestHeaders.Add("key", GoogleMapsAPIkey);

    using (HttpResponseMessage response = await client.GetAsync("geocode/json?address=1400,Copenhagen,DK"))
    {
        var responseContent = response.Content.ReadAsStringAsync().Result;
        response.EnsureSuccessStatusCode();
    }
}
Run Code Online (Sandbox Code Playgroud)

我发送查询字符串的最后一种方法GetAsync不起作用,我怀疑为什么会这样。当我 …

c# httpclient google-geocoding-api getasync

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

未在嵌入式 Power BI 报告中获取 report.getPages

在尝试从 .Net MVC 应用程序中的嵌入式 Power BI 报告获取视觉效果时,我尝试了来自嵌入式 Power BI Playground 网站的下面提到的代码。但我无法获得视觉效果。在调试时,我可以看到 Report 的 getPages 属性的值如下:

\n

getPages: \xc6\x92 ()arguments: null caller: null length: 0 name: ""

\n

还有console.log(report.getPages());给予

\n

[[PromiseStatus]]: "pending" [[PromiseValue]]: undefined

\n

PF 我尝试过的代码:

\n
// Get a reference to the embedded report HTML element\nvar embedContainer = $(\'#embedContainer\')[0];\n\n// Get a reference to the embedded report.\nreport = powerbi.get(embedContainer);\n\n// Retrieve the page collection and get the visuals for the first page.\nreport.getPages()\n    .then(function (pages) {\n        // Retrieve active page.\n …
Run Code Online (Sandbox Code Playgroud)

javascript powerbi powerbi-embedded

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

AttributeError: 'HTTPHeaderDict' 对象在 elasticsearch 中映射映射时没有属性 'get_all'

在这里,我添加了我的代码:


from datetime import datetime
from elasticsearch_dsl import Document, Date, Integer, Keyword, Text
from elasticsearch_dsl.connections import connections

# Define a default Elasticsearch client
connections.create_connection(hosts=['localhost'])

class Article(Document):
    title = Text(analyzer='snowball', fields={'raw': Keyword()})
    body = Text(analyzer='snowball')
    tags = Keyword()
    published_from = Date()
    lines = Integer()

    class Index:
        name = 'blog'
        settings = {
          "number_of_shards": 2,
        }

    def save(self, ** kwargs):
        self.lines = len(self.body.split())
        return super(Article, self).save(** kwargs)

    def is_published(self):
        return datetime.now() >= self.published_from

# create the mappings in elasticsearch
Article.init()
Run Code Online (Sandbox Code Playgroud)

在这里,我添加了我的elasticsearch …

python elasticsearch

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

春季启动 - @ControllerAdvice 不起作用

我正在使用Spring Boot 2.3.1,我尝试进行自定义ExceptionHandler

这是我的CustomHandler课:

@ControllerAdvice()
public class AppExceptionHandler extends ResponseEntityExceptionHandler{
    
        @ExceptionHandler(value = {Exception.class, RuntimeException.class, NullPointerException.class})
        public ResponseEntity<Object> handleAnyException(Exception ex, WebRequest request){
            System.out.println("===>App Exception was callled....!");
            return new ResponseEntity<>(
                    ex, new HttpHeaders(), HttpStatus.INTERNAL_SERVER_ERROR);
        }
      
    }
Run Code Online (Sandbox Code Playgroud)

我的项目结构:

在此处输入图片说明

我无法从这个类中得到任何响应,它似乎没有加载。

谢谢。

java exception nullpointerexception spring-boot

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

javax 自定义验证器的 Junit 测试用例

我正在 Spring Boot 应用程序中使用 javax 验证 API 进行跨字段验证。我有一个 User bean,我必须验证firstname两者lastname为空/空。该字段至少有一个应该有值。

我为此需求创建了自定义注释 ( NameMatch.java) 和自定义验证器 ( )。NameValidator.java

@NameMatch(first = "firstname", second = "lastname", message = "The first and lastname can't be null")
public class User  {

    private String firstname;

    private String lastname;

    @NotNull
    @Email
    private String email;

    @NotNull
    private String phone;
}
Run Code Online (Sandbox Code Playgroud)

名称匹配.java

@Target({TYPE, ANNOTATION_TYPE})
@Retention(RUNTIME)
@Constraint(validatedBy = NameValidator.class)
@Documented
public @interface NameMatch
{
    String message() default "{constraints.fieldmatch}";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] …
Run Code Online (Sandbox Code Playgroud)

java validation hibernate-validator spring-boot junit5

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

H2 数据库 - 抛出一般错误:“java.lang.IllegalStateException:无法读取位置 2199023614787 处的页面

我正在开发一个使用 H2 数据库的应用程序。过去使用此技术没有问题,但是在下载 h2 数据库的新副本并运行 jar 时,我无法使用默认设置登录!我正在跑步h2-1.4.200.jar并受到以下欢迎:

General error: "java.lang.IllegalStateException: Unable to read the page at position 2199023614787 [1.4.200/6]" [50000-200] HY000/50000 (Help)
Run Code Online (Sandbox Code Playgroud)

我试图运行默认设置只是为了连接到数据库,但似乎没有任何效果。我已经尝试了以下但没有运气,以及 github 等上的一些其他来源:

嵌入式 H2 数据库“NonTransientError: Unable to read the page at position”错误?

我在我的项目中使用以下依赖项:

    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>1.4.200</version>
    </dependency>
Run Code Online (Sandbox Code Playgroud)

并下载相应版本的H2数据库—— 1.4.200

过去有没有其他人在 H2 数据库上遇到过这样的问题?我收到的错误如下图所示:

H2 数据库控制台错误 1:

在此处输入图片说明

任何帮助将不胜感激,我还尝试在我的 maven 依赖项和运行的 h2 版本中降级到 1.4.190 版本 - h2-1.4.190

java database h2 h2db

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

Maven 可以从 POM 文件中引用 JAVA_HOME

是否可以参考 来在 POM 文件中设置属性$JAVA_HOME

<executable><$JAVA_HOME>/bin/javac</executable>
Run Code Online (Sandbox Code Playgroud)

我这样做的原因是我可以让 Maven 使用正确的编译器版本的唯一方法是通过设置<executable>. 但我不想JAVA_HOME在 pom 文件中硬编码该位置。

java maven

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

如何将字符串(例如“Sunday, July 4, 2021”)解析为 LocalDate?

我想一个字符串解析"Sunday, July 4, 2021"LocalDate,如下:

string this.selectedDate = "Sunday, July 4, 2021";
LocalDate date = LocalDate.parse(this.selectedDate);
Run Code Online (Sandbox Code Playgroud)

但我收到此错误:

java.time.format.DateTimeParseException: Text 'Sunday, July 4, 2021' could not be parsed at index 0
Run Code Online (Sandbox Code Playgroud)

如何将这样的字符串完整日期转换为 LocalDate?

java localdate localdatetime

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