雪化雨蝶

文章 评论 浏览 30

雪化雨蝶 2025-02-20 12:39:53

您可以尝试添加一个加载程序,

const [isLoading, setIsLoading] = useState(false);


// The render
if (isLoading) {
    return (
      <Text>I'm loading</Text>
    );
  }

如果用户获得授权并具有帐户,则可以添加使用效果,

  useEffect(() => {
   if(user have an account) {
      navigate('Screen');
    } else {
    // the the phone login screen can display
    setIsLoading(false)
    
    } 
   }, []);

最好的方法是在app.js中使用多个路由器

但 https://reaectnavigation.org/docs/auth-flow/“ rel =” nofollow noreferrer“> https://reactnavigation.org/docs/auth-flow/

You can try to add a loader, u can add

const [isLoading, setIsLoading] = useState(false);


// The render
if (isLoading) {
    return (
      <Text>I'm loading</Text>
    );
  }

And then in the useEffect if the user is authorized and has an account

  useEffect(() => {
   if(user have an account) {
      navigate('Screen');
    } else {
    // the the phone login screen can display
    setIsLoading(false)
    
    } 
   }, []);

But the best way is to have multiple router in your App.js

You can find an example here

https://reactnavigation.org/docs/auth-flow/

反应天然。火基。如何等待异步函数执行?

雪化雨蝶 2025-02-20 03:39:38

首先,您的 postdata 已经有一种列表。但是您正在尝试将其转换为不需要的列表。

  • 如果您希望模拟数据已经在列表类中。
    只需这样的测试:
import 'dart:async';

Future<List<Post>> _getPosts() async {
    return Future.delayed(Duration(milliseconds: 500))
        .then((onValue) => postList);
}
  • else,如果您希望您的MockData成为JSON并将其转换为 list&lt; post&gt;
    将您的模拟.json文件保存在资产/模拟文件夹中

class Post {
  final int index;
  final String headingText;
  final String bodyText;

  Post({
    this.index,
    this.headingText,
    this.bodyText,
  });

  factory Post.fromJson(Map<String, dynamic> data) {
    final index = data['index'] as int;
    final headingText = data['headingText'] as String;
    final bodyText = data['bodyText'] as String;
    return Post(index: index, headingText: headingText, bodyText: bodyText);
  }
}

,然后加载您的JSON文件 - &gt;将其转换 - &gt;返回

import 'dart:convert';
import 'package:flutter/services.dart';

Future<List<Post>> _getPosts() async {
    String response = await rootBundle.loadString('mock/your_file_name.json');
    Map<String, dynamic> parsedJson = json.decode(response);

    await Future.delayed(const Duration(seconds: 1));

    final postList = Post.fromJson(parsedJson);

    return postList;
  }

First of all, your postData is already has a type of List. But you're trying to convert it into List which is not necessary.

  • If you want your mock data to be already in List class.
    Just test it like this:
import 'dart:async';

Future<List<Post>> _getPosts() async {
    return Future.delayed(Duration(milliseconds: 500))
        .then((onValue) => postList);
}
  • Else, if you want your mockdata to be json and convert it into List<Post>,
    save your mock .json file in assets/mock folder

  • then, add factory constructor to Post class

class Post {
  final int index;
  final String headingText;
  final String bodyText;

  Post({
    this.index,
    this.headingText,
    this.bodyText,
  });

  factory Post.fromJson(Map<String, dynamic> data) {
    final index = data['index'] as int;
    final headingText = data['headingText'] as String;
    final bodyText = data['bodyText'] as String;
    return Post(index: index, headingText: headingText, bodyText: bodyText);
  }
}

then load your json file->convert it -> return it

import 'dart:convert';
import 'package:flutter/services.dart';

Future<List<Post>> _getPosts() async {
    String response = await rootBundle.loadString('mock/your_file_name.json');
    Map<String, dynamic> parsedJson = json.decode(response);

    await Future.delayed(const Duration(seconds: 1));

    final postList = Post.fromJson(parsedJson);

    return postList;
  }

Flutter:如何获得FutureBuilder来馈赠我的自定义小部件数据?

雪化雨蝶 2025-02-19 19:53:36

当“ todos”表具有“ status_id”时,

它必须“属于“状态”表。

或者,您应该将“ todo_id”保存在“状态”表中。

  // Status model
  Status.associate = (models) => {
    Status.hasMany(models.Todo, { foreignKey: 'status_id', as: 'todos' });
  };

  // Todo model
  Todo.associate = (models) => {
    Todo.belongsTo(models.Status, { foreignKey: 'status_id', as: 'status' });
  };

When the "Todos" table has the "status_id",

it must "belong to" the "Statuses" table.

Or you should save the "todo_id" in the "Statuses" table.

  // Status model
  Status.associate = (models) => {
    Status.hasMany(models.Todo, { foreignKey: 'status_id', as: 'todos' });
  };

  // Todo model
  Todo.associate = (models) => {
    Todo.belongsTo(models.Status, { foreignKey: 'status_id', as: 'status' });
  };

无法使用semelize添加外键约束

雪化雨蝶 2025-02-19 18:12:09

如果要单独的compialtion单元,则不要在命令行上指定所有源文件。一一汇编它们:

C++ -Wall -Wextra -Werror -E -o Foo.e Foo.cpp
C++ -Wall -Wextra -Werror -E -o Bar.e Bar.cpp

If you want separate compialtion units then don't specify all source files on the command line. Compile them one by one:

C++ -Wall -Wextra -Werror -E -o Foo.e Foo.cpp
C++ -Wall -Wextra -Werror -E -o Bar.e Bar.cpp

如何识别“ c&#x2b;&#x2B;”中每个编译单元的位置-e&quot输出

雪化雨蝶 2025-02-19 12:47:32

我目前正在使用NextJS版本12.3.1,如果我在Next.config.js中启用它,那么我会在终端上发出丑陋的警告。因此,最好只从“ next/future/image>”导入导入图像,而不是添加配置以避免警告。希望其他人使用12.3.1发现这个有用的(使用未来/图像可以摆脱

我在适当的位置上看到的警告:

ready - started server on 0.0.0.0:3000, url: http://localhost:3000
warn  - Invalid next.config.js options detected: 
  - The value at .experimental has an unexpected property, images, which is not in the list of allowed properties (adjustFontFallbacks, amp, appDir, browsersListForSwc, cpus, craCompat, disableOptimizedLoading, disablePostcssPresetEnv, esmExternals, externalDir, fallbackNodePolyfills, forceSwcTransforms, fullySpecified, gzipSize, incrementalCacheHandlerPath, isrFlushToDisk, isrMemoryCacheSize, largePageDataBytes, legacyBrowsers, manualClientBasePath, modularizeImports, newNextLinkBehavior, nextScriptWorkers, optimizeCss, optimisticClientCache, outputFileTracingRoot, pageEnv, profiling, proxyTimeout, runtime, scrollRestoration, serverComponents, sharedPool, sri, swcFileReading, swcMinify, swcMinifyDebugOptions, swcPlugins, swcTraceProfiling, urlImports, workerThreads).

See more info here: https://nextjs.org/docs/messages/invalid-next-config
warn  - You have enabled experimental feature (images) in next.config.js.
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.

I'm currently working with NextJS version 12.3.1, and if I enable it in the next.config.js then I get an ugly warning on the terminal. So it is best to just import Image from "next/future/image" and not add the config to avoid the Warning. Hope others using 12.3.1 find this useful ( using future/image gets rid of the nasty wrapper divs/spans around the )

Warning I'm seeing with config in place:

ready - started server on 0.0.0.0:3000, url: http://localhost:3000
warn  - Invalid next.config.js options detected: 
  - The value at .experimental has an unexpected property, images, which is not in the list of allowed properties (adjustFontFallbacks, amp, appDir, browsersListForSwc, cpus, craCompat, disableOptimizedLoading, disablePostcssPresetEnv, esmExternals, externalDir, fallbackNodePolyfills, forceSwcTransforms, fullySpecified, gzipSize, incrementalCacheHandlerPath, isrFlushToDisk, isrMemoryCacheSize, largePageDataBytes, legacyBrowsers, manualClientBasePath, modularizeImports, newNextLinkBehavior, nextScriptWorkers, optimizeCss, optimisticClientCache, outputFileTracingRoot, pageEnv, profiling, proxyTimeout, runtime, scrollRestoration, serverComponents, sharedPool, sri, swcFileReading, swcMinify, swcMinifyDebugOptions, swcPlugins, swcTraceProfiling, urlImports, workerThreads).

See more info here: https://nextjs.org/docs/messages/invalid-next-config
warn  - You have enabled experimental feature (images) in next.config.js.
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.

如何启用nextjs&quot&quot&quot&quot&quot&quot?

雪化雨蝶 2025-02-19 11:24:51

由于JavaScript的事件循环,推动方法在您的情况下无法使用。
二人组合功能的异步行为,在堆栈更新您的数组之前,功能会启动功能。

Because of the JavaScript's event loop the push method won't work in your scenario.
Duo to the async behavior of your functions the function fires off before the stack updates your array.

为什么尽管推动了元素,但我的温度阵列是否在第二使用效果中不包含元素?

雪化雨蝶 2025-02-19 10:36:54

类成员:

虚拟 destructor需要实现。

声明destructor纯净仍需要您定义它(与常规功能不同):

struct X
{
    virtual ~X() = 0;
};
struct Y : X
{
    ~Y() {}
};
int main()
{
    Y y;
}
//X::~X(){} //uncomment this line for successful definition

发生这种情况是因为当对象被隐式破坏时,因此调用了基础类破坏者,因此需要定义。

虚拟必须实现或定义为纯净的方法。

这类似于非定义的非虚拟方法,并增加了推理
纯声明会生成一个虚拟的VTable,您可能会在无需使用函数的情况下获得链接器错误:

struct X
{
    virtual void foo();
};
struct Y : X
{
   void foo() {}
};
int main()
{
   Y y; //linker error although there was no call to X::foo
}

为此,声明 x :: foo() us pure:

struct X
{
    virtual void foo() = 0;
};

non- virtual 班级成员

即使不明确使用一些成员,也需要定义一些成员:

struct A
{ 
    ~A();
};

以下将产生错误:

A a;      //destructor undefined

实现可以在类别定义本身中进行内联:

struct A
{ 
    ~A() {}
};

或外部:

A::~A() {}

如果实现不在类的定义之外,则 可以标头,必须将方法标记为 inline 以防止多重定义。

如果使用的话,所有使用的成员方法都需要定义。

一个常见的错误是忘记限定名称:

struct A
{
   void foo();
};

void foo() {}

int main()
{
   A a;
   a.foo();
}

定义应为

void A::foo() {}

静态必须在单个翻译单元中定义类数据成员:

struct X
{
    static int x;
};
int main()
{
    int x = X::x;
}
//int X::x; //uncomment this line to define X::x

可以为A提供初始化器 static const 集体定义中积分或枚举类型的数据成员;但是,该成员的ODR使用仍需要如上所述的名称空间范围定义。 C ++ 11允许在所有 static const 数据成员的类中初始化。

Class members:

A pure virtual destructor needs an implementation.

Declaring a destructor pure still requires you to define it (unlike a regular function):

struct X
{
    virtual ~X() = 0;
};
struct Y : X
{
    ~Y() {}
};
int main()
{
    Y y;
}
//X::~X(){} //uncomment this line for successful definition

This happens because base class destructors are called when the object is destroyed implicitly, so a definition is required.

virtual methods must either be implemented or defined as pure.

This is similar to non-virtual methods with no definition, with the added reasoning that
the pure declaration generates a dummy vtable and you might get the linker error without using the function:

struct X
{
    virtual void foo();
};
struct Y : X
{
   void foo() {}
};
int main()
{
   Y y; //linker error although there was no call to X::foo
}

For this to work, declare X::foo() as pure:

struct X
{
    virtual void foo() = 0;
};

Non-virtual class members

Some members need to be defined even if not used explicitly:

struct A
{ 
    ~A();
};

The following would yield the error:

A a;      //destructor undefined

The implementation can be inline, in the class definition itself:

struct A
{ 
    ~A() {}
};

or outside:

A::~A() {}

If the implementation is outside the class definition, but in a header, the methods have to be marked as inline to prevent a multiple definition.

All used member methods need to be defined if used.

A common mistake is forgetting to qualify the name:

struct A
{
   void foo();
};

void foo() {}

int main()
{
   A a;
   a.foo();
}

The definition should be

void A::foo() {}

static data members must be defined outside the class in a single translation unit:

struct X
{
    static int x;
};
int main()
{
    int x = X::x;
}
//int X::x; //uncomment this line to define X::x

An initializer can be provided for a static const data member of integral or enumeration type within the class definition; however, odr-use of this member will still require a namespace scope definition as described above. C++11 allows initialization inside the class for all static const data members.

什么是未定义的参考/未解决的外部符号错误,我该如何修复?

雪化雨蝶 2025-02-19 04:36:59

我刚才复制了您的 Importerror ,但随后奏效了:

!pip install -U dask
!pip install dask_bigquery

# restart runtime at this point

import dask_bigquery

I reproduced your ImportError just now, but then this worked:

!pip install -U dask
!pip install dask_bigquery

# restart runtime at this point

import dask_bigquery

无法在colab中导入dask_query软件包

雪化雨蝶 2025-02-18 17:40:09

线索:: SOLVE_LSAP 使用匈牙利算法。 Jonker and Volgenant(1987)算法,在 ,更有效。

我测试了矩阵的简化版本,以在几秒钟而不是分钟内获得结果。运行时间的差异可能会随着较大的矩阵而增加。

gower <- read.csv("GowerDistance.csv")
dim(gower)
gowerMat <- as.matrix(gower)
gow1 <- gowerMat[1:2400, 1:4800]
tictoc::tic()
clue <- clue::solve_LSAP(gow1, maximum = FALSE)
tictoc::toc()
# 67.95 sec elapsed
tictoc::tic()
td <- TreeDist::LAPJV(gow1)
tictoc::toc()
# 20.24 sec elapsed

graphAlignment :: linearassignment() 还使用LAPJV算法,但只能应用于方形矩阵。 (解决方法是在具有极高值的矩阵中添加额外的行。)

另一种选择是 /a>;这没有指定使用哪种算法,但要慢得多

tictoc::tic()
lps <- lpSolve::lp.assign(gowerMat[1:800, 1:1600]) # much smaller matrix
tictoc::toc()
# 364.67 sec elapsed

clue::solve_LSAP uses the Hungarian algorithm. The Jonker and Volgenant (1987) algorithm, implemented in TreeDist::LAPJV(), is more efficient.

I tested a reduced version of the matrix to get results in seconds rather than minutes; differences in run time are likely to increase with larger matrices.

gower <- read.csv("GowerDistance.csv")
dim(gower)
gowerMat <- as.matrix(gower)
gow1 <- gowerMat[1:2400, 1:4800]
tictoc::tic()
clue <- clue::solve_LSAP(gow1, maximum = FALSE)
tictoc::toc()
# 67.95 sec elapsed
tictoc::tic()
td <- TreeDist::LAPJV(gow1)
tictoc::toc()
# 20.24 sec elapsed

GraphAlignment::LinearAssignment() on Bioconductor also uses the LAPJV algorithm, but can only be applied to square matrices. (A workaround is to add extra rows to the matrix with extremely high values.)

Another alternative is lpSolve; this does not specify which algorithm it uses, but is much slower

tictoc::tic()
lps <- lpSolve::lp.assign(gowerMat[1:800, 1:1600]) # much smaller matrix
tictoc::toc()
# 364.67 sec elapsed

线性总和分配/R中的匈牙利方法性能

雪化雨蝶 2025-02-18 13:12:17

这是投掷错误,因为您的命令不知道您的命令使用哪种连接。初始化时,您需要将连接传递到 mySqlCommand

var cmd = new MySqlCommand("SELECT _Password FROM * WHERE email=" + enter_email);
cmd.Connection = connection; // <- add this row

It's throw error because your command doesn't know which connection your command use. You need to pass your connection to your MySqlCommand when initialize.

var cmd = new MySqlCommand("SELECT _Password FROM * WHERE email=" + enter_email);
cmd.Connection = connection; // <- add this row

system.invalidoperationException:&#x27;连接属性不得为null&#x27;在MySQL连接中

雪化雨蝶 2025-02-18 04:40:34

我不确定为什么要遇到权限错误,但是在目录上使用打开不会做您想要的。 documentation python的 open> open 要求,要求这样它的输入是 file 的字符串,而不是目录

如果将目录中的文件命名为字符串,请参阅我如何迭代给定目录中的文件?

I'm not sure why you're getting a permission error, but using open on a directory won't do what you want. The documentation for Python's open requires that its input is a string to a file, not a directory.

If you want the files in a directory given the name of the directory as a string, refer to How can I iterate over files in a given directory?

我如何用argparse打开文件夹

雪化雨蝶 2025-02-18 02:17:20

您可以将列分为“ end_cols”和“其他_cols”,然后将它们传递给选择器 -

# Borrowing @mozway's df
end_col = ['X'] 
other_cols = [col for col in df.columns if col not in end_col]
df[other_cols + end_col]

output

   A  B  C  X
0  a  b  c  x

You can split the columns into "end_cols" and "other_cols" and pass them back to the selector -

# Borrowing @mozway's df
end_col = ['X'] 
other_cols = [col for col in df.columns if col not in end_col]
df[other_cols + end_col]

Output

   A  B  C  X
0  a  b  c  x

将数据框列移至最后一列

雪化雨蝶 2025-02-18 01:37:15

您可以使用它来获取应用程序正在侦听的URL,但只有在运行之后才能获取该URL。

您可以尝试一下。但是我不确定它如何适合您的解决方案。

await app.StartAsync();

Console.WriteLine($"Urls from Program.cs after app.StartAsync(): {string.Join(", ", app.Urls)}");

await app.WaitForShutdownAsync();

you can use this to get urls on which your application is listening but only after it is running.

You can try this. but I am not sure how it will fit into your solution.

await app.StartAsync();

Console.WriteLine(
quot;Urls from Program.cs after app.StartAsync(): {string.Join(", ", app.Urls)}");

await app.WaitForShutdownAsync();

如何在.NET 6中获取WebApp的基本URL

雪化雨蝶 2025-02-18 00:54:44

您可以从 data.table 之间使用之间

library(data.table)

# convert do date
data_cols <- grep("date$", names(data), value = TRUE)
setDT(data)[, (data_cols) := lapply(.SD, as.Date, "%m/%d/%y"), .SDcols = data_cols]

# calculate
data[Prod_date %between% list(initial_date, third_date)][,.(avg_oil = mean(OIL)), by = PROPNUM]

You can use %between% from data.table:

library(data.table)

# convert do date
data_cols <- grep("date
quot;, names(data), value = TRUE)
setDT(data)[, (data_cols) := lapply(.SD, as.Date, "%m/%d/%y"), .SDcols = data_cols]

# calculate
data[Prod_date %between% list(initial_date, third_date)][,.(avg_oil = mean(OIL)), by = PROPNUM]

获取需要匹配R中其他列条件的平均条件

雪化雨蝶 2025-02-17 23:10:37
const theme = createTheme({
    direction: "rtl",
  });

  return (
    <ThemeProvider theme={theme}>
      <Rating name="simple-controlled" />
    </ThemeProvider>
  );
const theme = createTheme({
    direction: "rtl",
  });

  return (
    <ThemeProvider theme={theme}>
      <Rating name="simple-controlled" />
    </ThemeProvider>
  );

MUI评级组件正在渲染恢复

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文