小编Raz*_*aza的帖子

Puppeteer - 如何填写iframe内的表单?

我必须填写一个iframe内的表单,这里是示例页面.我无法通过简单地使用page.focus()和访问page.type().我试图通过使用获取表单iframe const formFrame = page.mainFrame().childFrames()[0],但是我无法与表单iframe进行交互.

puppeteer

15
推荐指数
3
解决办法
9093
查看次数

Vue Trigger腕表已安装

我有一个下面的vue组件,我想看它在安装时触发.我怎么做?

Vue.component('check-mark', {
    name: 'check-mark',
    template: `
    <input :value="value">
    `,
    props: {
        value: {
            type: String,
            required: true,
        },
    },
    mounted: async function () {
        //trigger this.value watch() here
    },
    watch: {
        value: function (value) {
            if (value == 'Y') {
                this.class = 'checked';
            } else {
                this.class = 'unchecked';
            }
        },
    },
});
Run Code Online (Sandbox Code Playgroud)

vue.js vue-component vuejs2

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

NestJS:将服务注入模型/实体

我目前被困在一个问题上,我不知道如何解决:

在我的 NestJS 应用程序中,我想让我的所有TypeORM Entities扩展BaseEntity类都提供一些通用功能。例如,我想提供一种额外的getHashedID()方法来散列(并因此隐藏)我的 API 客户的内部 ID。

散列是由 a 完成的HashIdService,它提供了一个encode()anddecode()方法。

我的设置看起来像这样(删除了装饰器以提高可读性!):

export class User extends BaseEntity {
  id: int;
  email: string;
  name: string;
  // ...
}

export class BaseEntity {
  @Inject(HashIdService) private readonly hashids: HashIdService;

  getHashedId() {
    return this.hashids.encode(this.id);
  }
}
Run Code Online (Sandbox Code Playgroud)

但是,如果我调用该this.hashids.encode()方法,它会抛出一个异常:

Cannot read property 'encode' of undefined
Run Code Online (Sandbox Code Playgroud)

我怎样才能把inject一个服务变成一个entity/model类?这甚至可能吗?

更新 #1 特别是,我想“注入”HashIdService到我的Entities. 此外,Entities应该有一个 …

entity dependency-injection nestjs

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

Java Swing:延迟后更改文本

基本上,我有这个游戏,一旦猜到正确答案,它开始一个新单词的新游戏.我想显示Correct!但三秒后,将其更改为空字符串.我怎么做?

我的尝试:

if (anagram.isCorrect(userInput.getText()))
    {

        anagram = new Anagram();
        answer.setText("CORRECT!");
        word.setText(anagram.getRandomScrambledWord());
        this.repaint();
        try
        {
        Thread.currentThread().sleep(3000);
        }
        catch (Exception e)
        {
        }
        answer.setText("");

    } else
    {
        answer.setForeground(Color.pink);
        answer.setText("INCORRECT!");
    }
Run Code Online (Sandbox Code Playgroud)

编辑:

我的解决方案

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)
    {
        // TODO add your handling code here:
    if (anagram.isCorrect(userInput.getText()))
    {
        answer.setText("CORRECT!");

        ActionListener taskPerformer = new ActionListener()
    {
    public void actionPerformed(ActionEvent evt)
    {
        anagram = new Anagram();
        word.setText(anagram.getRandomScrambledWord());
        answer.setText("");
        userInput.setText("");
    }
    };
    Timer timer = new Timer(3000, taskPerformer);
    timer.setRepeats(false);
    timer.start();
    } else
    {
        answer.setForeground(Color.pink); …
Run Code Online (Sandbox Code Playgroud)

java swing timer delay

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

Pandas 绘制按时间分组的条形图

我在下面有一个表格,我想在分组条形图中绘制它。我想要 x 轴time_period和 y 轴death_licenses,我想被分类civic_centre。如您所见,对于每个不同的time_period, 中有四个分类选项civic_centre

+-------------+--------------+----------------+
| time_period | civic_centre | death_licenses |
+-------------+--------------+----------------+
| 2011-01-01  | ET           |            410 |
| 2011-01-01  | NY           |            681 |
| 2011-01-01  | SC           |            674 |
| 2011-01-01  | TO           |            297 |
| 2011-02-01  | ET           |            307 |
| 2011-02-01  | NY           |            388 |
| 2011-02-01  | SC           |            407 |
| 2011-02-01  | TO           |            223 …
Run Code Online (Sandbox Code Playgroud)

python matplotlib pandas

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