我试图定义一种异步函数,但编译失败,见下文:
interface SearchFn {
async (subString: string): string;
}
class A {
private Fn: SearchFn
public async do():Promise<string> {
await this.Fn("fds") // complain here: cannot invoke an expression whose type lacks a call signature
return ''
}
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我解决这个问题吗?
因为bootstrap3,我的很多html会像这样结束:
<div class="form-group">
<label class="control-label col-xs-4 col-sm-6">Name on card</label>
<div class="col-xs-8 col-sm-6">
<input class="form-control" type="text" placeholder="Name on Card" required />
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-4 col-sm-6">Card Number</label>
<div class="col-xs-8 col-sm-6">
<input class="form-control" type="text" placeholder="Card Number" name="EWAY_CARDNUMBER" required value="4444333322221111" />
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
参见上面的代码,标签节点有不同的媒体屏幕类.我想简单地用他们自己的课来缩短它们.
我试图减少创建一个从多个类扩展的类
my-control-label:extend(.control-label, .col-xs-4, col-sm-6){}
Run Code Online (Sandbox Code Playgroud)
但这不起作用,因为较少使用完全匹配上述示例.是的我可以尝试扩展"all",如下所示:
my-control-label:extend(.control-label all, .col-xs-4 all, col-sm-6 all){}
Run Code Online (Sandbox Code Playgroud)
但它很烦人,它会破坏生成的CSS.
那么有什么简单的方法可以避免这种重复吗?
谢谢,罗恩
更新#1:
甚至扩展所有对我的情况都不起作用
HTML
<div id='finalise'>
<form class='form-horizontal'>
<div class='form-group' >
<label class='my-label' />
<div class='my-controls'>
<input class="form-control" type="text" placeholder="Name on …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用webpack开发一个angular2应用程序,但最终在浏览器控制台中出现错误说:未捕获的ReferenceError:系统未定义.
当我查看捆绑的js时,我看到它正在使用System.register,如下所示:
function(module, exports) {
System.register(['angular2/platform/browser', './app.component'], function(exports_1) {
var browser_1, app_component_1;
return {
setters:[
function (browser_1_1) {
browser_1 = browser_1_1;
},
function (app_component_1_1) {
app_component_1 = app_component_1_1;
}],
execute: function() {
browser_1.bootstrap(app_component_1.AppComponent);
}
}
});
// ...
Run Code Online (Sandbox Code Playgroud)
我的webpack.config.js非常简单,如下所示:
var webpack = require('webpack');
module.exports = {
context: __dirname,
entry: "./app/boot.ts",
devtool: 'inline-sourcemap',
output: {
path: __dirname + "/dist",
filename: "bundle.js"
},
module: {
loaders: [
{test: /\.ts$/, loader: 'ts-loader'}
]
}
};
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我解决?谢谢.
我正在通过https://registry.hub.docker.com/_/postgres/上的官方postgres图像来尝试docker postgres .
在文档中,它运行以下命令并使其工作:
docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres
docker run -it --link some-postgres:postgres --rm postgres sh -c 'exec psql -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres'
Run Code Online (Sandbox Code Playgroud)
所以我的问题是$ POSTGRES_PORT_5432_TCP_PORT和$ POSTGRES_PORT_5432_TCP_ADDR来自哪里?
我正在学习jenkins管道,我试着遵循这个管道代码.但我的詹金斯总是抱怨这def不合法.我想知道我是否错过任何插件?我已经安装了groovy,job-dsl但是没有用.
假设有一个“addUser”函数,里面我们需要向“Account”表和“User”表插入一条记录,所以这两个步骤也必须在一个事务中,所以我们将编写如下代码:
function addUser (userName, password) {
sequelize.transaction(function () {
return AccountModel.create(...)
.then(UserModel.create(...))
})
}
Run Code Online (Sandbox Code Playgroud)
但是,在另一个“addTeam”函数中,我们需要在“Team”表中插入一条记录并使用上述函数创建一个管理员用户。该函数还需要包含在事务中。
那么问题来了,“addUser”函数有时需要开始一个新的事务,有时需要使用传入的事务。最明显的方式如下:
function addUser (userName, password, transaction) {
let func = function (t) {
return AccountModel.create(..., t)
.then(()=>UserModel.create(..., t)));
if (transaction) func(t);
else sequelize.transaction(x=>func(t));
}
function addTeam() {
sequelize.transaction(x=> {
TeamModel.create(..., x)
.then(y=>addUser(x));
});
}
Run Code Online (Sandbox Code Playgroud)
显然,这很可怕。如何轻松处理它,让交易对调用者完全透明,如下所示:
@Transaction
async function addUser(userName, password) {
await AccountModel.create(...);
await UserModel.create(...);
}
@Transaction
async function addTeam(...) {
await TeamModel.create(...);
await addUser(...);
}
Run Code Online (Sandbox Code Playgroud) 想知道是否faunadb支持实时,支持哪个是大事firebase?
我注意到faunadb支持graphql但没有subscription支持。
对不起,如果这个问题很幼稚?
我是 opencart 的新手,我对 opencart 中扩展和模块之间的术语感到困惑,谁能向我解释一下?
根据这个问题jsonschema attribute conditionally required,我可以应用条件必需的属性。但是,它只能依赖于同一级别对象的属性。在某些情况下,我希望所需的一个属性依赖于其父对象属性,这可能吗?对于下面的例子:
{
type: 'object',
properties: {
{
os: { type: 'string', enum: ['macOs', 'windows'] },
specs: {
macModel: {
type: 'string',
enum: ['macbook air', 'macbook pro', 'macbook']
},
memory: { type: 'number' }
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
是否可以满足这个要求:仅当/os等于macOs时才需要/spec/macModel?
使用 es6,我可以从库中只导入一个函数来最小化整个包,例如:
import merge from "lodash/merge"
但是,在typescript中,上面这句话会导致编译错误:Cannot find module "lodash/merge"。如何解决?
我的要求是有一个函数可以有效地返回数组。
据我所知,数组是值类型,因此当将输入/输出数组传递给函数时,它会这样做copy。因此,我正在考虑数组的返回指针。人们会推荐使用切片,但是通过使用切片,我仍然需要copy转移到数组。
这是游乐场包含两种解决方案,请建议返回数组指针是否是正确的方法,谢谢。
package main
import (
"fmt"
)
type geo [2]float32
func genArray () geo {
ret := geo{1.2, 2.3}
return ret
}
func genPointerOfArray () *geo {
ret := geo{1.2, 2.3}
return &ret
}
func main() {
ret1 := genArray()
ret2 := *genPointerOfArray()
fmt.Println(ret1, ret2)
}
Run Code Online (Sandbox Code Playgroud) 我使用mongoose连接mongo(v3.04)副本集,我想将所有请求传播到set中的所有节点.但是,在完成以下操作后,我的辅助设备从未被命中,我的连接字符串和选项如下:
let connectionString = 'mongodb://ip1:27017/db, ip2:27017/db';
mongoose.connect(connectionString, {
server: {
socketOptions: {keepAlive: 1},
readPreference: "nearest",
strategy: "ping"
},
replset: {
rs_name: 'ReplicaSet',
socketOptions: {keepAlive: 1},
strategy: 'ping',
readPreference: 'nearest',
poolSize: 10
}
});
Run Code Online (Sandbox Code Playgroud)
看起来mongoose完全忽略了我传递的readPreference设置.我已经尝试了很多方法,但到目前为止还没有运气.任何人都可以给我一个提示?
node.js ×2
typescript ×2
angular ×1
angularjs ×1
css ×1
docker ×1
faunadb ×1
go ×1
html ×1
javascript ×1
jenkins ×1
jsonschema ×1
less ×1
mongodb ×1
opencart ×1
sequelize.js ×1
validation ×1
webpack ×1