小编Chr*_*ais的帖子

在TypeScript中使用process.env

如何在TypeScript中读取节点环境变量?

如果我使用process.env.NODE_ENV我有这个错误:

Property 'NODE_ENV' does not exist on type 'ProcessEnv'
Run Code Online (Sandbox Code Playgroud)

我安装@types/node但没有帮助.

node.js typescript

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

在打字稿中使用Winston

我无法想象如何在打字稿中使用记录模块Winston.我尝试设置记录器级别时出错,而当我尝试记录错误时出现另一个错误:

import * as logger from "winston";

logger.level = 'debug';
// [ts] Cannot assign to 'level' because it is a constant or a read-only property.

logger.error(new Error('test'));
// [ts] Argument of type 'Error' is not assignable to parameter of type 'string'.
Run Code Online (Sandbox Code Playgroud)

我已经加入既winston@types/winston我的项目.


编辑:完成约书亚的回答,似乎默认情况下,温斯顿登录到......无处可去.您必须添加一个传输才能使其工作:

import * as logger from "winston";

logger.configure({
    level: 'debug',
    transports: [
        new logger.transports.Console({
            colorize: true
        })
    ]
});
Run Code Online (Sandbox Code Playgroud)

winston typescript

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

Firestore 对子集合的规则

我在 firestore 上有一个“游戏”集合,其中包含一个“级别”子集合。我正在尝试设置安全规则,以便您只能访问您创建的游戏或关卡。

所有文档(游戏或关卡)都有一个authorId字段,其中包含创建它们的用户的 uid。我已经尝试过这个规则,但仍然出现Missing or insufficient permissions错误:

service cloud.firestore {
  match /databases/{database}/documents {    
    match /games/{document=**} {
        allow read, write: if document.data.authorId == request.auth.uid;
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我错过了什么?

我也尝试了以下规则但没有成功:

service cloud.firestore {
  match /databases/{database}/documents {    
    match /games/{game}/levels/{level} {
        allow read, write: if level.data.authorId == request.auth.uid;
    }
  }
}
Run Code Online (Sandbox Code Playgroud)
service cloud.firestore {
   match /games/{game} {
     allow read, write: if game.data.authorId == request.auth.uid;     

       match /levels/{level} {
          allow read, write: if level.data.authorId == request.auth.uid;
       }
    }
}
Run Code Online (Sandbox Code Playgroud)

firebase firebase-security google-cloud-firestore

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

使用<include>标记内的EditText的奇怪行为

我有一个视图,其中包含另一个带有"include"组件的视图(请参阅http://android-developers.blogspot.com/2009/02/android-layout-tricks-2-reusing-layouts.html)
有一些EditText在包含的视图内.

这些EditText存在一些问题:

  • 为了让键盘出现,我必须点击它们2次
  • 如果我长按EditText中的一个应用程序冻结和崩溃(仅在我的手机上 - 三星galaxy S,而不是在模拟器上)

如果Edittext不在<include>标签中就不会发生......
你对这个问题有任何想法吗?

问候,克里斯托夫

android android-layout

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

导入 vuetify 指令的正确方法是什么?

导入 vuetify 内置指令的正确方法是什么?像这个

我正在这样做,这有效但看起来有点糟糕:

import { Vuetify, VApp, VNavigationDrawer, VProgressLinear, VList, VBtn, VIcon, VGrid, VToolbar } from 'vuetify';
import * as directives from 'vuetify/es5/directives';

Vue.use(Vuetify, {
  components: { VApp, VNavigationDrawer, VProgressLinear, VList, VBtn, VIcon, VGrid, VToolbar },
  directives,
  theme: {
    ...
  }
});
Run Code Online (Sandbox Code Playgroud)

后来在我的.vue文件中:

<template>
  <div v-resize="resize">
    ...
  </div>
</template>

<script>
  export default {
    methods: {
      resize() {
        ...
      }
    }
  };
</script>
Run Code Online (Sandbox Code Playgroud)

注意:接受的答案适用于 Vuetify 1,对于 Vuetify 2,请参阅下面的我的答案。

vuetify.js

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

HTML5 画布上的多点/颜色渐变

我想用从不同位置的几种不同颜色创建的渐变填充 html5 画布上的形状,就像这张图片一样

你对我如何做到这一点有什么想法吗?

javascript gradient html5-canvas

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