我想将此 docker CLI 命令(来自Smallstep/step-ca)转换为 docker-compose.yml 文件以运行docker compose(版本 2):
docker run -d -v step:/home/step \
-p 9000:9000 \
-e "DOCKER_STEPCA_INIT_NAME=Smallstep" \
-e "DOCKER_STEPCA_INIT_DNS_NAMES=localhost,$(hostname -f)" \
smallstep/step-ca
Run Code Online (Sandbox Code Playgroud)
此命令成功启动容器。
这是我“撰写”的撰写文件:
version: "3.9"
services:
ca:
image: smallstep/step-ca
volumes:
- "step:/home/step"
environment:
- DOCKER_STEPCA_INIT_NAME=Smallstep
- DOCKER_STEPCA_INIT_DNS_NAMES=localhost,ubuntu
ports:
- "9000:9000"
Run Code Online (Sandbox Code Playgroud)
当我运行时docker compose up(再次,在这里使用 v2),我收到此错误:
服务“ca”指的是未定义的卷步骤:无效的撰写项目
这是解决这个问题的正确方法吗?我想我错过了在 docker compose 项目中创建卷的额外步骤,但我不确定那会是什么,或者这是否是一个有效的用例。
我是 Blazor 新手,正在尝试了解不同托管模型之间的差异。
根据我的阅读,我了解到 Blazor 服务器端和 Blazor WebAssembly Hosted 都有服务器端代码,两者都使用 Signal R 与客户端通信。
那么它们之间有什么区别呢?这些的客户端部署在哪里?他们与Server的连接有什么区别?如果 Web 应用程序依次调用第 3 方 Web API,则调用如何路由?
我发现的一个区别在于项目结构。Blazor 服务器端只有一个项目(带有数据文件夹)。Blazor WebAssembly Hosted 有 3 个项目(.Server、.Client 和 .Shared)。
我最近开始通过 SvelteKit 使用 Svelte,我对这个框架有一些疑问,但我无法在源代码/文档中找到任何直接答案:
如果您需要从外部 API 请求数据,所有服务器端代码(包括端点)都可以访问 fetch。
谢谢!
prerender server-side-rendering svelte netlify-function sveltekit
我HttpGet在我的 Server-API 中创建了一个 CSV 文件并返回它FileStreamResult:
[HttpGet]
public IActionResult Get() {
// do logic to create csv in memoryStream
return new FileStreamResult(memoryStream, "text/csv;charset=utf-8") {
FileDownloadName = "products.csv",
};
}
Run Code Online (Sandbox Code Playgroud)
在我的 Blazor-Client 应用程序中,我创建了一个带有处理程序的按钮:
private async Task DownloadCatalog() {
var file = HttpClient.GetAsync("api/csvProduct");
// ... how do I download the file in the browser?
}
Run Code Online (Sandbox Code Playgroud)
调用了控制器中的 Get,但我不知道该怎么做才能在 api 调用后将文件下载到浏览器中。
我正在尝试在基于 .NET Core 2.1 的 C# 控制台应用程序中登录并运行。
我在 DI 声明中添加了以下代码:
var sc = new ServiceCollection();
sc.AddLogging(builder =>
{
builder.AddFilter("Microsoft", LogLevel.Warning);
builder.AddFilter("System", LogLevel.Warning);
builder.AddFilter("Program", LogLevel.Warning);
builder.AddConsole();
builder.AddEventLog();
});
Run Code Online (Sandbox Code Playgroud)
我试图通过在服务Microsoft.Extensions.Logging.ILogger的构造函数中使用接口来注入服务,但出现以下错误:
未处理的异常:System.InvalidOperationException:尝试激活“MyService”时无法解析“Microsoft.Extensions.Logging.ILogger”类型的服务。
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(ResultCache lifetime, Type serviceType, Type implementationType, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor descriptor, Type serviceType, CallSiteChain callSiteChain, Int32 slot)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(Type serviceType, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite(Type serviceType, CallSiteChain callSiteChain)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, …Run Code Online (Sandbox Code Playgroud) 我有一个名为 Hello 的 JavaScript 事件:
addEventListener('hello', function () {
alert("event listener");
})
Run Code Online (Sandbox Code Playgroud)
并且,在另一个 javascript 函数中,我引发了该事件:
let event = new Event("hello", { bubbles: true });
document.dispatchEvent(event);
Run Code Online (Sandbox Code Playgroud)
我现在想做的是让事件在 javascript 函数中触发。Blazor 应该侦听事件,而不是调用 Blazor 方法的 javascript。
希望任何人都可以帮助我。
问候我,
我有一个在 VS Code 中构建的 React 项目。我正在使用 Webpack,所以我想添加一些别名:
module.exports = {
resolve: {
extensions: ['.js', '.jsx'],
alias: {
Config$: path.resolve(__dirname, 'config.js'),
Css: path.resolve(__dirname, 'src/client/resources/css'),
Client: path.resolve(__dirname, 'src/client')
}
}
// etc...
Run Code Online (Sandbox Code Playgroud)
所以我在我的项目中引用了内容,例如在 ./src/client/index.js 中:
import 'Css/util.scss';
Run Code Online (Sandbox Code Playgroud)
该项目按预期运行。问题是 VS Code Intellisense 无法识别别名,尽管jsconfig.json我的项目根目录中存在 a :
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"Config": [
"./config.js"
],
"Css/*": [
"./src/client/resources/css/*"
],
"Client/*": [
"./src/client/*"
],
},
},
"exclude": [
"node_modules",
"dist"
]
}
Run Code Online (Sandbox Code Playgroud)
尝试自动完成或导航到在 VS Code 中加载了别名的文件的位置失败,并且我的 ESLint 将其视为错误:
我想通过操作将更改应用于 vuejs 应用程序中的变量。但我收到这个错误说[vuex] unknown local mutation type: updateValue, global type: app/updateValue
这是我的商店文件夹结构:
-store
-modules
-app
-actions.js
-getters.js
-mutations.js
-state.js
-index.js
-actions.js
-getters.js
-mutations.js
-state.js
-index.js
Run Code Online (Sandbox Code Playgroud)
这是我的./store/index.js文件:
-store
-modules
-app
-actions.js
-getters.js
-mutations.js
-state.js
-index.js
-actions.js
-getters.js
-mutations.js
-state.js
-index.js
Run Code Online (Sandbox Code Playgroud)
这是我的./store/modules/index.js:
import Vue from 'vue'
import Vuex from 'vuex'
import actions from './actions'
import getters from './getters'
import modules from './modules'
import mutations from './mutations'
import state from './state'
Vue.use(Vuex)
const store = new …Run Code Online (Sandbox Code Playgroud) 我将今天遇到的问题简化为这个最小的示例。(游乐场链接)
function test() {
interface Foo<T> {
type: 'Bar'
}
function nextFoo<T>(it: Foo<T>): Foo<T> {
return it
}
let foo: Foo<string> | undefined = { type: 'Bar' }
while (foo !== undefined) {
// Type inference error here but TS has the correct inference when hovering over nextFoo
const next = nextFoo(foo)
foo = next // commenting this out masks the issue
}
}
Run Code Online (Sandbox Code Playgroud)
这似乎是 TypeScript 应该能够处理的事情。当我将鼠标悬停nextFoo在 vscode 中时,它看起来确实正确地推断出那里的类型。设置foo为nextwhile 它可能会undefined导致这种情况。 …