问题列表 - 第292046页

StencilJS 在 HTML 文件中使用组件

我想在常规的基本 HTML 文件中使用使用 StencilJS 创建的组件。我按照以下步骤操作:

我创建了一个模板组件来创建基本的 my-component 示例:

npm init stencil
Run Code Online (Sandbox Code Playgroud)

我想在 HTML 文件中使用这个组件,所以我跑了

npm run build
Run Code Online (Sandbox Code Playgroud)

然后我创建了一个具有以下结构的 html 项目:

在此处输入图片说明

然后我将文件从 dist 文件夹移动到脚本文件夹中。我在引用 component.js 文件的 html 文件的头部添加了脚本标记,如下所示:

<script src="script/{component_name}/{component_name}.js"></script>
Run Code Online (Sandbox Code Playgroud)

我在 html 中使用了这样的组件:

<my-component first="Stencil" last="'Don't call me a framework' JS"></my-component>
Run Code Online (Sandbox Code Playgroud)

但是我的组件没有被渲染。我收到一个涉及 esm.js 文件的错误。有人可以帮助我完成编译模板组件以在基本 HTML 项目中使用的过程吗?

html javascript stenciljs

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

如何通过转义关闭 Angular Material Sidenav?

我的目标是通过按 escape 来关闭Angular Material Sidenav

我尝试使用该[autoFocus]="true"属性来实现此目的,但没有帮助。

问题是按转义键没有效果 -只有当我第一次在侧导航内部单击时按转义键才会起作用。

我在这里分叉了一个官方示例来演示该问题,因此您可以尝试一下代码。

我不确定这是否是侧导航的错误,或者只是我无法弄清楚如何捕获焦点。

angular-material angular

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

C++ std::string 初始化性能更好(汇编)

我在玩 www.godbolt.org 来检查哪些代码会生成更好的汇编代码,但我不明白为什么这两种不同的方法会生成不同的结果(在汇编命令中)。

第一种方法是声明一个字符串,然后再设置一个值:

#include <string>
int foo() {
    std::string a;
    a = "abcdef";
    return a.size();
}
Run Code Online (Sandbox Code Playgroud)

其中,在我的 gcc 7.4 ( -O3) 输出中:

.LC0:
        .string "abcdef"
foo():
        push    rbp
        mov     r8d, 6
        mov     ecx, OFFSET FLAT:.LC0
        xor     edx, edx
        push    rbx
        xor     esi, esi
        sub     rsp, 40
        lea     rbx, [rsp+16]
        mov     rdi, rsp
        mov     BYTE PTR [rsp+16], 0
        mov     QWORD PTR [rsp], rbx
        mov     QWORD PTR [rsp+8], 0
        call    std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned …
Run Code Online (Sandbox Code Playgroud)

c++ optimization

6
推荐指数
1
解决办法
214
查看次数

如何转换 Kafka Connect 中的多个字段?

我正在使用 Kafka Connect Sink 配置从主题获取数据并将其保存到 Oracle 数据库。工作起来就像冠军一样,我正在对通过 Avro 模式作为 long 传入的时间戳列进行转换,然后转换为 Oracle Timestamp 列。

"transforms": "TimestampConverter",
"transforms.TimestampConverter.type": "org.apache.kafka.connect.transforms.TimestampConverter$Value",
"transforms.TimestampConverter.format": "mm/dd/yyyy HH:mm:ss",
"transforms.TimestampConverter.target.type": "Timestamp",
"transforms.TimestampConverter.field": "created_ts"
Run Code Online (Sandbox Code Playgroud)

但是,我不知道如何在多个时间戳上执行此操作。也就是说,除了created_ts之外,我还有一个需要改造的updated_ts。

我试过这个:

"transforms.TimestampConverter.field": "created_ts, updated_ts"
Run Code Online (Sandbox Code Playgroud)

不起作用,我也无法为其他字段重复整个块,因为 Connect 只允许 1 个同名条目。

最后,我尝试了这个:

"transforms.TimestampConverter.field.1": "created_ts",
"transforms.TimestampConverter.field.2": "updated_ts"
Run Code Online (Sandbox Code Playgroud)

apache-kafka-connect

4
推荐指数
1
解决办法
2537
查看次数

StreamWriter 在文件末尾写了一个奇怪的行

I'm using a StreamWriter to write a string to memory and then return it as a file via an IActionResult in an ASP.Net Core Web API, and I'm running into a weird issue where I'm getting a line of indecipherable characters at the end of the output file...

Here's an image of what I'm talking about:

在此处输入图片说明

The text on line 513 is not supposed to be there... I'm thinking it has something to do with encoding, but I don't know …

c# .net-core asp.net-core

0
推荐指数
1
解决办法
76
查看次数

python - get a list of first values in dictionary

I have a dictionary like so:

look_up = {1: ('January', str(now.year + 1) + '-01-01', '2020-01-31', 'E'),
           2: ('February', str(now.year + 1) + '-02-01', '2020-02-29', 'F'),
           3: ('March', str(now.year + 1) + '-03-01', '2020-03-31', 'G'),
           4: ('April', str(now.year + 1) + '-04-01', '2020-04-30', 'H'),
           5: ('May', str(now.year + 1) + '-05-01', '2020-05-31', 'I'),
           6: ('June', str(now.year + 1) + '-06-01', '2020-06-30', 'J'),
           7: ('July', str(now.year + 1) + '-07-01', '2020-07-31', 'K'),
           8: ('August', str(now.year + 1) + '-08-01', '2020-08-31', 'L'), …
Run Code Online (Sandbox Code Playgroud)

python dictionary list

0
推荐指数
1
解决办法
76
查看次数

验证服务描述符“ServiceType: INewsRepository Lifetime: Singleton ImplementationType: NewsRepository”时出错:

我尝试使用存储库模式从我的数据库中获取数据我有 3 个项目

Bmu.Mode '这是用于创建数据库的模型'

Bmu.Repo '它有 2 个文件夹用于存储库,包括 contract/InewsRepository.cs' 和用于实现接口的 'Repository/NewsRepository'

Bmu.Api 用于从 Repo 项目调用数据

模型项目中的新闻类

namespace bmu.model
{
   public class News
   {
    public int Id { get; set; }

    public string SubTitle { get; set; }

    public string Title { get; set; }

    public string Summery { get; set; }
  }
}
Run Code Online (Sandbox Code Playgroud)

模型项目中的上下文类

namespace bmu.model
 {
   public class BmuContext : DbContext
    {
       public BmuContext(DbContextOptions<BmuContext> options): base(options)
      {

      }
    public DbSet<News> News { get; set; }
   }
}
Run Code Online (Sandbox Code Playgroud)

我在 …

c# repository repository-pattern asp.net-core-mvc asp.net-core-3.0

11
推荐指数
4
解决办法
6万
查看次数

在 C# 中替换字符串模式

我里面有几句话是我想解码的一些单词。

要删除的单词的模式是“&.....;”

.... = 一切

<title>??&#1740;????? ??????? ????? ???? ??????&#1740; ?&#1740;??? ?? ???? ???&#1740;??? ?&#1740;??&#1740; ???&#1740;? ????&#1740;??? ??????? ????? ?????? &#1740;??? . </title>
Run Code Online (Sandbox Code Playgroud)

c#

0
推荐指数
1
解决办法
67
查看次数

如何在 Python 中求解非线性三角方程组(MATLAB 可以轻松求解)

我正在尝试用 Python 求解非线性三角方程组。我尝试了以下方法:

from sympy import symbols,solve,sin,cos,pi, Eq

measurements = [(5.71403,0.347064), (4.28889, -0.396854), (5.78091, -7.29133e-05), 
(2.06098, 0.380579), (8.13321, 0.272391), (8.23589, -0.304111), (6.53473, 0.265354), (1.6023, 
0.131908)]

f, a, phi = symbols('f a phi')
eq1 = Eq(a*sin((2.0*pi*f*measurements[0][0])+phi) - measurements[0][1])
eq2 = Eq(a*sin((2.0*pi*f*measurements[4][0])+phi) - measurements[4][1])
eq3 = Eq(a*sin((2.0*pi*f*measurements[6][0])+phi) - measurements[6][1])
solve((eq1,eq2,eq3), (a, f, phi))
Run Code Online (Sandbox Code Playgroud)

Python 需要花很长时间来尝试求解方程。但是,MATLAB 可以立即完成。

有什么问题?

python numpy sympy scipy

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

我们何时以及为什么需要 ApplicationRunner 和 Runner 接口?

我正在学习 Spring Boot。ApplicationRunner 或任何运行器接口的典型用例是什么?

import org.junit.jupiter.api.Test;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
class PersistencedemoApplicationTests implements ApplicationRunner {

    @Test
    void contextLoads() {
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
       // load initial data in test DB
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我知道的一个案例。还要别的吗?

java spring spring-boot

16
推荐指数
1
解决办法
1万
查看次数