kubectl port-forwarding(将端口从本地主机转发到集群中的 pod 以获取对集群资源的访问权限)和 NodePort 服务类型之间有什么区别?
当我在顶层使用“await”时,如下所示:
const LuckyDrawInstance=await new web3.eth.Contract(abi)
Run Code Online (Sandbox Code Playgroud)
我在终端上收到警告:“设置experiments.topLevelAwait true”。当我尝试将其添加到“tsconfig.json”时,它仍然不起作用。它说“实验”财产不存在。
我可以将它包装在异步函数中,但我想在没有包装函数的情况下设置它。
我试图使用 typescript 将 Redis (v4.0.1) 连接到我的 Express 服务器,但遇到了一些问题。正在学习打字稿。它在redis.createClient()内的主机上显示红线有人可以帮助我吗?
const host = process.env.REDIS_HOST;
const port = process.env.REDIS_PORT;
const redisClient = redis.createClient({
host,
port,
});
Run Code Online (Sandbox Code Playgroud)
Argument of type '{ host: string | undefined; port: string | undefined; }' is not assignable to parameter of type 'Omit<RedisClientOptions<never, RedisScripts>, "modules">'.
Object literal may only specify known properties, and 'host' does not exist in type 'Omit<RedisClientOptions<never, RedisScripts>, "modules">'.ts(2345)
Run Code Online (Sandbox Code Playgroud) 从这个答案和这篇文章中,我添加了一个,<Script>以便将 Google 跟踪代码管理器添加到我的 NextJS 网站:
components/layout.tsx:
import React from "react";
import Head from "next/head";
import Script from 'next/script'
<!-- skip some code -->
<Head>
<link rel="preconnect" href="https://cdn.sanity.io/" />
<link rel="dns-prefetch" href="https://cdn.sanity.io//" />
</Head>
<Script id="google-tag-manager" strategy="afterInteractive">
{
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id=%27+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-xxxx');
}
</Script>
Run Code Online (Sandbox Code Playgroud)
但是,该脚本不存在于前端。
components/layout.tsx<Head>是我的网站上唯一带有或 的文件<head>。
Google 跟踪代码管理器<noscript>位于前端,用于app/layout.tsx:
<body className="antialiased text-gray-800 dark:bg-black dark:text-gray-400">
<noscript
dangerouslySetInnerHTML={{
__html: <iframe src="https://www.googletagmanager.com/ns.html?id=xxxx" height="0" width="0" style="display: none; visibility: hidden;" …Run Code Online (Sandbox Code Playgroud) 我运行了anchor test --skip-deploy,它应该做的就是初始化我的程序,但我得到的只是这个错误,我无法解决。我检查了 tsconfig.json 设置,它们应该没问题。这只是默认的锚点设置,我不会在任何地方导入任何不寻常的 JSON 文件。
锚点测试 --skip-deploy BPF SDK:/Users/julia/.local/share/solana/install/releases/1.9.5/solana-release/bin/sdk/bpf Cargo-build-bpf 子项:rustup 工具链列表 - v Cargo-build-bpf 子项:cargo +bpf build --target bpfel-unknown-unknown --release 警告:未使用的变量:
ctx-->programs/feeRedeemCounter/src/lib.rs:8:23 | 8 | pub fn 初始化(ctx: Context) -> ProgramResult { | ^^^ 帮助:如果这是故意的,请在其前面添加下划线:_ctx| = 注意:#[warn(unused_variables)]默认开启警告:
feeRedeemCounter(lib)生成了 1 个警告在 1.28s 中完成了发布 [优化] 目标 Cargo-build-bpf 子项:/Users/julia/.local/share/solana/install/releases/1.9.5/solana-release /bin/sdk/bpf/dependencies/bpf-tools/llvm/bin/llvm-readelf --dyn-symbols /Users/julia/Downloads/anchorTutorial/feeRedeemCounter/target/deploy/fee_redeem_counter.so要部署此程序: $ solana program deploy /Users/julia/Downloads/anchorTutorial/feeRedeemCounter/target/deploy/fee_redeem_counter.so 程序地址将默认为此密钥对(使用 --program-id 覆盖):/Users/julia/ Downloads/anchorTutorial/feeRedeemCounter/target/deploy/fee_redeem_counter-keypair.json 纱线运行 v1.22.17 警告 package.json:没有许可证字段 $ /Users/julia/Downloads/anchorTutorial/feeRedeemCounter/node_modules/.bin/ts-mocha -p ./tsconfig.json -t 1000000 '测试/**/*.ts' …
我正在创建这样的对话:
llm = ChatOpenAI(temperature=0, openai_api_key=OPENAI_API_KEY, model_name=OPENAI_DEFAULT_MODEL)
conversation = ConversationChain(llm=llm, memory=ConversationBufferMemory())
Run Code Online (Sandbox Code Playgroud)
但我真正想要的是能够保存和加载它,ConversationBufferMemory()以便它在会话之间保持不变。似乎没有任何明显的教程,但我注意到“Pydantic”,所以我尝试这样做:
saved_dict = conversation.memory.chat_memory.dict()
cm = ChatMessageHistory(**saved_dict) # or cm = ChatMessageHistory.parse_obj(saved_dict)
Run Code Online (Sandbox Code Playgroud)
但这失败了:
ValidationError: 6 validation errors for ChatMessageHistory
messages -> 0
Can't instantiate abstract class BaseMessage with abstract method type (type=type_error)
Run Code Online (Sandbox Code Playgroud)
想法?我希望有任何类型的指南、存储库、参考资料等的链接。
我正在使用react redux形式字段,我有下拉类.我可以从下拉菜单中选择任何一个班级.但问题是,当我从下拉列表中选择任何值(类)时,我想触发onChange操作.当我用on on触发动作时,下拉值没有设置,也没有显示选定的值.我正在使用以下代码行
<Field name="class._id" component="select" className="form-control" onChange={this.onChange.bind(this)} >
<option value="">Select class...</option>
{this.props.classes.map(Class =>
<option value={Class._id} key={Class._id} >{Class.name}</option>)}
</Field>
Run Code Online (Sandbox Code Playgroud)
这里是onChange函数
onChange(){
console.log(" Triggered")
}
Run Code Online (Sandbox Code Playgroud)
如果我没有设置onChange事件,我的下拉工作正确,它会正确显示所选值和正确的文本.但是我想在每次使用时调用函数选择任何值
我正在构建下一个项目的打字稿。如果我将此配置文件保留为next.config.js,我会收到一条警告tsconfig.json“未找到 next.config.ts”。所以 tsconfig.json 上有警告标志{}。
如果我将扩展名更改为.ts,当我启动项目时,我会收到以下错误:
“错误:不支持通过‘next.config.ts’配置 Next.js。请将该文件替换为‘next.config.js’。”
我很困惑,我不知道该怎么办。
ts.config.json
{
"compilerOptions": {
"target": "es6",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
},
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"sourceMap": true,
"removeComments": true,
"jsx": "preserve"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
Run Code Online (Sandbox Code Playgroud)
下一个.config.ts
const path = require("path");
const Dotenv = require("dotenv-webpack");
module.exports = {
env: …Run Code Online (Sandbox Code Playgroud) 我正在使用 nextJs 版本 11.x
当尝试包含如下所示的外部脚本时,执行纱线构建时出现错误。
<Head>
<link rel="stylesheet" type="text/css" href="http://www.externalsite.com/style.css" />
<script src="https://www.websote.com/viewer.min.js"></script>
</Head>
Run Code Online (Sandbox Code Playgroud)
错误 :
./pages/_app.js
63:17 Error: External synchronous scripts are forbidden. See: https://nextjs.org/docs/messages/no-sync-scripts. @next/next/no-sync-scripts
Run Code Online (Sandbox Code Playgroud)
我正在使用 eslint。
那么,我们如何包含这个外部js呢?
我正在尝试在某个事件中重新验证我网站的所有页面,
我遇到的问题是我必须一页一页地做:
...
try {
await res.unstable_revalidate(
`/`
);
await res.unstable_revalidate(
`/about`
;
await res.unstable_revalidate(
`/shop`
);
...
return res.json({ revalidated: true });
} catch (err) {
return res.status(500).send('Error revalidating');
}
Run Code Online (Sandbox Code Playgroud)
所以我的问题是:有没有一种方法可以按需(使用unstable_revalidate())重新验证我网站的所有页面,或者我是否必须逐页进行?
next.js ×5
reactjs ×4
javascript ×3
typescript ×3
node.js ×2
anchor ×1
express ×1
kubernetes ×1
langchain ×1
next.js13 ×1
node-redis ×1
pydantic ×1
python ×1
react-redux ×1
redis ×1
redux ×1
redux-form ×1
rust ×1
solana ×1
testing ×1
webpack ×1