我刚刚开始使用 Material UI 5.0.4(带有styled-components),我想在组件中访问主题。我在网上查了一下useTheme,所以我检查了文档并找到了它- @mui/styles/useTheme。但是,它是遗留文档,并且@mui/styles在 MUI 5 中不存在。因此,我查看了@mui/system,并找到了“访问组件中的主题”部分。然而,这只是指向遗留文档!
在文档似乎对我没有帮助之后,我决定使用 Visual Studio Code 的“快速修复”功能,如果您将鼠标悬停在该函数上,VSCode 将为您提供要导入的选项列表。以下是我尝试过的选项列表以及它们不起作用的原因:
@mui/material/styles/useTheme- 无论如何,返回默认主题对象。查看源代码,这实际上就是它的作用- 它切换到默认主题,然后返回主题。@mui/material/private-theming/useTheme- 这才回来null。我觉得我无论如何都不应该访问这个(它说private-),但我还是尝试了。@mui/system/useTheme- 这就是我希望能起作用的。然而,这也可能是最奇怪的一个。它为我提供了默认主题,但排除了许多属性。例如,它只提供了palette.mode,除此之外没有其他键palette。(你可以在下面看到整个事情){
"breakpoints": {
"keys": ["xs", "sm", "md", "lg", "xl"],
"values": { "xs": 0, "sm": 600, "md": 900, "lg": 1200, "xl": 1536 },
"unit": "px"
},
"direction": "ltr",
"components": {},
"palette": { "mode": "light" …Run Code Online (Sandbox Code Playgroud) 所以,这是我第一次深入 ASP.NET。我以前用 C# (Unity) 编程过,但从未制作过 ASP.NET 应用程序。问题是,我似乎无法让 SSL 工作!当我使用这些步骤创建新项目时,出现以下错误:
但是,当我转到“属性”>“调试”并取消选中“启用 SSL”时,它工作得非常好。我也尝试过使用 Microsoft Edge,但它给出了相同的错误。这是我尝试解决此问题的方法:
applicationhost.config中的文件.vs(源).vs文件夹并运行命令(更多信息请点击此处)netsh http show iplisten- 未列出任何内容(来源)localhost(来源)正如你所看到的,我已经尝试了我想到的一切。有人可以解释一下为什么会发生这种情况吗?重申一下,当我不更改按照这些步骤获得的任何默认代码时,就会发生这种情况,因此它不可能是超时或其他原因。
我将IIS Express 10.0( …
因此,我最近重新回到机器学习领域,并决定开始“ConnectX”的 Kaggle 课程(https://www.kaggle.com/learn/intro-to-game-ai-and-reinforcement-learning)。我正在尝试做第 4 课,其中我使用稳定基线 + Tensorflow 来制作人工智能。问题是,我似乎无法正确使用稳定基线,因为当我尝试导入它时它立即给我一个错误。这是错误消息:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-13-f5986851ce81> in <module>
1 import os
----> 2 from stable_baselines.bench import Monitor
3 from stable_baselines.common.vec_env import DummyVecEnv
4
5 # Create directory for logging training information
~\Anaconda3\lib\site-packages\stable_baselines\__init__.py in <module>
----> 1 from stable_baselines.a2c import A2C
2 from stable_baselines.acer import ACER
3 from stable_baselines.acktr import ACKTR
4 from stable_baselines.deepq import DQN
5 from stable_baselines.her import HER
~\Anaconda3\lib\site-packages\stable_baselines\a2c\__init__.py in <module>
----> 1 from stable_baselines.a2c.a2c import …Run Code Online (Sandbox Code Playgroud) const App = () => {
const [myMutation] = useMutation(gql`
mutation Test($updateUserId: ID!, $updateUserInput: UpdateUserInput!) {
updateUser(id: $updateUserId, input: $updateUserInput) {
id
firstname
age
}
}
`);
// Runs every time this component is rendered
console.log("rendered");
// Called when the button is clicked
const update = () => {
myMutation({
variables: {
updateUserId: 1,
updateUserInput: {
age: Math.round(Math.random() * 10 + 5) // Set a random age from 5 - 15
}
}
});
};
return (
<>
<h1>Update …Run Code Online (Sandbox Code Playgroud) 对于不和谐机器人和 python 以及构建反垃圾邮件机器人来说非常陌生,这是我的代码:
import discord
from discord.ext import commands
import time
b = commands.Bot(command_prefix='not a bot')
b.remove_command("help")
@b.event
async def on_ready():
print('Bot is Ready')
authors = {}
authors1 = []
@b.event
async def on_message(ctx):
global authors
global authors1
author_id = ctx.author.id
for author2 in authors1:
if author_id == author2:
authors[author_id] += 1
else:
authors[author_id] = 1
authors1.append(author_id)
stop = False
timer = 5
while stop == False:
if timer > 0:
time.sleep(0.985)
timer -= 1
if authors[author_id] > 5:
await …Run Code Online (Sandbox Code Playgroud) 我已经研究 Rust 的宏系统有一段时间了,最近对将两个宏嵌套在一起感兴趣,如下所示:
macro_rules! foo {
() => {
macro_rules! bar {
() => {}
}
}
}
Run Code Online (Sandbox Code Playgroud)
关于该示例,我想动态地创建bar!传入的参数名称foo!,以获得如下结果:
foo!(bar, baz);
// The above call creates a macro, bar!, with the following definition:
macro_rules! bar {
( $bar:literal, $baz:literal ) => {
println!("{}", stringify!( $bar, $baz ));
}
}
Run Code Online (Sandbox Code Playgroud)
为了更好地了解我想要做什么,这是我关于它如何工作的最初思考过程(这应该完全解析为上面显示的定义):
macro_rules! foo {
( $( $attr:ident ), * ) => {
macro_rules! bar {
// the designator $$attr:literal consists of two parts - $attr,
// which …Run Code Online (Sandbox Code Playgroud) 我试图创建一个遵循构建器模式并且在编译时完全运行的类(使用constevalC++20 中的 new 关键字),但无论我尝试什么都不起作用。例如,这是行不通的:
#include <vector>
class MyClass
{
private:
std::vector<int> data;
public:
consteval MyClass& setData()
{
this->data = {20};
return *this;
}
consteval std::vector<int> build()
{
return data;
}
};
int main()
{
std::vector<int> data = MyClass().setData().build();
}
Run Code Online (Sandbox Code Playgroud)
这给出了错误“<anonymous>不是常量表达式”。这让我相信我应该返回该类的副本:
#include <vector>
class MyClass
{
private:
std::vector<int> data;
public:
consteval MyClass setData()
{
// https://herbsutter.com/2013/04/05/complex-initialization-for-a-const-variable/
return [&]{
MyClass newClass;
newClass.data = {20};
return newClass;
}();
}
consteval std::vector<int> build()
{
return data;
}
};
int main() …Run Code Online (Sandbox Code Playgroud) 我已经在 Visual Studio Code 上使用 WSL2 和 C/C++ 扩展有一段时间了,但最近它停止工作了。每当我尝试运行命令(例如编辑配置)时,都会弹出此错误:
文字版:
命令“C/C++:编辑配置 (UI)”导致错误(未找到命令“C_Cpp.ConfigurationEditUI”)
请注意,该扩展中的每个命令都会发生这种情况,而其他命令则可以正常工作(包括来自其他扩展的命令)。我的 IntelliSense 也停止正常工作(当我单击CTRL+SPACE等时什么也没有出现)。
我多次尝试重新安装扩展程序,包括转到以前的版本、删除文件夹、重新启动计算机等,但没有任何帮助。控制台中似乎也没有错误。
这种情况发生在我安装了VSCode 的 PROS 扩展之后,该扩展恰好依赖于clangd,我认为这就是问题所在(我使用的是 Linux 的 Windows 子系统,这意味着该扩展安装在 Ubuntu 上,并且我使用 GNU GCC /G++ 编译器)。有谁知道我该如何解决这个问题?(我不想重新安装 Visual Studio Code 或做任何激烈的事情,因为我有很多扩展和很多配置,如果这样做就会丢失)。
c++ ×2
python ×2
reactjs ×2
apollo ×1
asp.net ×1
builder ×1
c# ×1
c++20 ×1
discord ×1
discord.py ×1
material-ui ×1
python-3.x ×1
rust ×1
rust-macros ×1
ssl ×1
tensorflow ×1
time ×1