小编Hei*_*itx的帖子

Nodejs、TypeScript、ts-node-dev 和顶级 await

在需要顶级等待之后,我现在花了一个小时寻找新错误的解决方案。到目前为止我尝试过的所有其他方法都没有解决错误,例如添加"type": "module"到 package.json 文件中。

错误消息是Cannot use import statement outside a module在启动服务时。如果我将更改恢复"module": "ESNext","module": "commonjs",,它工作正常(除了必须删除 await 关键字并以某种方式重构以在没有等待的情况下工作)。

另外,我使用 ts-node-dev 来运行服务,可以在 package.json 文件中看到。

  • 我需要的新包是 kafkajs。
  • 节点版本:v14.9.0
  • 打字稿版本:4.0

包.json

{
  "name": "",
  "version": "1.0.0",
  "description": "microservice",
  "main": "src/index.ts",
  "author": "",
  "type": "module",
  "license": "MIT",
  "scripts": {
    "dev": "NODE_ENV=development tsnd --respawn --files src/index.ts",
    "prod": "NODE_ENV=production tsnd --respawn --transpile-only --files src/index.ts",
    "test": "mocha --exit -r ts-node/register tests/**/*.spec.ts",
    "eslint": "eslint src/**/*.ts"
  },
Run Code Online (Sandbox Code Playgroud)

配置文件

{
  "compilerOptions": {
    "target": "ES2020",
    "module": …
Run Code Online (Sandbox Code Playgroud)

node.js async-await typescript top-level-await

17
推荐指数
3
解决办法
3615
查看次数

LayerInstantiationException - 两个模块中的软件包许可证有什么解决方案吗?

我有三个名为 core、common 和 item 的模块,每个模块都是 Maven 项目的子模块。我正在使用 ServiceLoader 来实现服务方法,并使用 Java 11 和 fontawesomefx 11(最新)。

我没有使用过 Java 的模块系统,所以我不知道我对模块信息文件的处理是否正确。然而,核心和项目模块都需要 fontawesomefx 模块,并且会导致以下错误:

Error occurred during initialization of boot layer
java.lang.LayerInstantiationException: Package license in both module de.jensd.fx.fontawesomefx.materialicons and module de.jensd.fx.fontawesomefx.materialdesignicons
Run Code Online (Sandbox Code Playgroud)

所有子模块的模块信息:

module common {
    requires javafx.graphics;
    requires javafx.controls;
    requires de.jensd.fx.fontawesomefx.commons;
    exports common.abstractions;
    exports common.services;
    exports common.sidebar;
    opens common.services;
}

module core {
    requires common;
    requires javafx.controls;
    requires javafx.fxml;
    requires de.jensd.fx.fontawesomefx.materialdesignicons;
    uses common.services.ISidebarPlugin;
    exports core.ui to javafx.graphics;
    exports core.ui.mainpage to javafx.fxml;
    exports core.ui.sidebar to javafx.fxml; …
Run Code Online (Sandbox Code Playgroud)

font-awesome java-module java-11 javafx-11

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

如何在 Vue 路由器中定义要在组件内部使用的变量?

我在顶部有一个导航栏,在<router-view>其右下方有一个导航栏(如 中所示App.vue)。我希望导航栏中的标题根据我所在的路线/视图而改变。由于我的视图<router-view>不包含标题本身,因此我需要在某处定义它们。该场景的一个示例是,当到达路线时/login,导航栏中的标题更改为“登录”。我该如何实现这一目标?

在寻找解决方案时,我遇到了很多页面标题问题。我不是在谈论document.title作业,但是,这可能是一种解决方案,但不是一个完美的解决方案。如果我希望标题不是文档标题,该怎么办?

应用程序.vue:

<template>
  <Menu :isActive="isMenuActive" />
  <Navbar @toggle:hamburger="onHamburgerToggle($event)" />
  <router-view />
</template>
Run Code Online (Sandbox Code Playgroud)

html css vue-router vue-component vuejs3

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