如何在TypeScript中读取节点环境变量?
如果我使用process.env.NODE_ENV我有这个错误:
Property 'NODE_ENV' does not exist on type 'ProcessEnv'
Run Code Online (Sandbox Code Playgroud)
我安装@types/node但没有帮助.
我无法想象如何在打字稿中使用记录模块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) 我在 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) 我有一个视图,其中包含另一个带有"include"组件的视图(请参阅http://android-developers.blogspot.com/2009/02/android-layout-tricks-2-reusing-layouts.html)
有一些EditText在包含的视图内.
这些EditText存在一些问题:
如果Edittext不在<include>标签中就不会发生......
你对这个问题有任何想法吗?
问候,克里斯托夫
导入 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,请参阅下面的我的答案。
我想用从不同位置的几种不同颜色创建的渐变填充 html5 画布上的形状,就像这张图片一样。
你对我如何做到这一点有什么想法吗?
typescript ×2
android ×1
firebase ×1
gradient ×1
html5-canvas ×1
javascript ×1
node.js ×1
vuetify.js ×1
winston ×1