小编Jan*_*nka的帖子

Yii2:如何将Pagination-Per-Page更改为RESTful Web Service API?

我正在使用AngularJS为前端开发应用程序,为后端使用Yii2.

前端需要全面的所有用户.

在Yii2的文档中,http://www.yiiframework.com/doc-2.0/guide-rest-quick-start.html 我可以读取按X-Pagination-Per-Page划分的结果:20

如何设置X-Pagination-Per-Page:ALL?

rest pagination yii2

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

SQLite连接中的新行字符\n

我知道,在某些编程语言中,如果您执行以下操作:

'This is on first line \n This is on second line'
Run Code Online (Sandbox Code Playgroud)

然后它会像这样正确显示:

This is on first line
This is on second line
Run Code Online (Sandbox Code Playgroud)

当我在SQLite数据库中连接一个字符串时

SELECT *, [FIELD1] || '\n'  || [FIELD2] from TABLE
Run Code Online (Sandbox Code Playgroud)

(其中[FIELD1] =这是在第一行[FIELD2] =这是在第二行)

它显示如下:

This is on first line \n This is on second line
Run Code Online (Sandbox Code Playgroud)

有没有理由不正确显示\n字符?

sqlite newline

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

Kubernetes ingress 如何设置default-ssl-certificate?

我有一个通用 SSL 证书 *.domain.com 我想为 4 级域 (my4.level.domain.com) 配置 HTTPS 我在本讨论中读到,我需要使用 --default-ssl-certificate

但我不明白如何使用它

我应该如何更改此配置?

ingress:
  enabled: true
  annotations: {}
  labels: {}
  path: /
  hosts:
    - my4.level.domain.com
  extraPaths: []
  tls:
   - secretName: tls-tierra-ingress
     hosts:
       - '*.level.domain.com'
       - level.domain.com
       - my4.level.domain.com
Run Code Online (Sandbox Code Playgroud)

或者我必须运行特殊命令?

kubernetes-helm kubernetes-ingress

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

适用于Firefox的chrome.webrequest.onbeforerequest.addlistener?

Google Chrome在其chrome.webrequest API中包含一些功能(例如,http: //developer.chrome.com/extensions/samples.html#12a7bf1490a26359eadf10917e37c5b9),可用于将某些网址重定向到指定的网页.Chrome扩展程序使用阻止事件侦听器(chrome.webRequest.onBeforeRequest.addListener)并对目标网址执行重定向.我如何在FireFox附加组件中做类似的事情?

google-chrome webrequest firefox-addon google-chrome-extension firefox-addon-webextensions

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

如何通过exec进程在node js中强制UTF-8?

我知道解决方案很简单,但我花了一个小时才解决这个问题。

\n\n

Windows 10中,如果我启动命令“ dir ”,我得到以下结果:

\n\n

Il 卷 nell\'unit\xc3\xa0 D non ha etichetta。

\n\n

Node.js中中,我尝试以这种方式执行 dir 命令:

\n\n
var child = exec(\'dir\', {\'encoding\': \'UTF-8\'}, (err, stdout, stderr) => {\n  console.log(stdout);\n});\n
Run Code Online (Sandbox Code Playgroud)\n\n

我得到了这个结果:\n Il 卷 nell\'unit\xef\xbf\xbd C non ha etichetta。

\n\n

啊,该死的带口音的信!

\n\n

我尝试使用 UTF-16,然后转换为字符串:

\n\n
var child = exec(\'dir\', {\'encoding\': \'UTF-16\'}, (err, stdout, stderr) => {\n  let b: Buffer = stdout;\n  let o: string;\n  o = stdout.toString(\'UTF-8\');\n  console.log(o);\n});\n
Run Code Online (Sandbox Code Playgroud)\n\n

我得到了同样的诅咒结果:

\n\n

“Il 卷 nell\'unit\xef\xbf\xbd C …

exec utf-8 utf-16 node.js

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

Angular 2和网络工作者

angular 2如何使用Web worker在后台运行进程?这样做我应该遵循什么模式?

我试过这个:

npm i @angular/platform-webworker
npm i @angular/platform-webworker-dynamic
npm i @angular/platform-webworker
ng serve
Run Code Online (Sandbox Code Playgroud)

到app.module.ts我添加:

import {WorkerAppModule} from '@angular/platform-webworker';
//import {platformWorkerAppDynamic} from '@angular/platform-webworker-dynamic';
//import {ServiceMessageBrokerFactory, PRIMITIVE} from '@angular/platform-webworker';

@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    BrowserModule,
    FormsModule,
    WorkerAppModule,
    HttpModule,
  ],
  providers: [CommentService],
  bootstrap: [AppComponent]
})
Run Code Online (Sandbox Code Playgroud)

Angular 2正确编译,但在http:// localhost:4200 / i中出现此错误:

zone.js:524 DOMException:无法在'Window'上执行'postMessage':在'postMessage'调用中无效的目标原点''.

我喜欢在背景中使用服务

service web-worker angular

5
推荐指数
0
解决办法
1778
查看次数

如何分析loki存储空间?

今天 Loki 使用的磁盘空间已满。Loki 中是否有仪表板或功能来识别哪些 PODS 生成了最多的日志?

除了洛基金丝雀之外还有什么?

我从未使用过这个工具,我不知道它是否适合我

grafana-loki

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

RxJs如何在ReplaySubject中引发异常?

我有一个有角度的2服务

import * as localforage from "localforage";
import { ReplaySubject } from 'rxjs/ReplaySubject';

@Injectable()
export class CommentService {
    private localForage = require("localforage");

    addComment (myvalue: string): Observable<Comment[]> {
        var reply:ReplaySubject<any> = new ReplaySubject(1);
        localforage.setItem(that.key, that.elencoCommenti).then(function (value) {
            //throw new Error("Value cannot be 3");
            reply.throw(Error('Error2'));           
            //              reply.next( value );
            //              reply.complete();
        });
        return reply;
    }

}
Run Code Online (Sandbox Code Playgroud)

该服务结合了提出异常的方法.当我尝试订阅

submitComment(){
    // Variable to hold a reference of addComment
    let commentOperation:Observable<string>;

    commentOperation = this.commentService.addComment(this.model)

    // Subscribe to observable
    commentOperation.subscribe(
                            comments => {
                                console.log('ok:');
                                console.log(comments);
                            }, …
Run Code Online (Sandbox Code Playgroud)

error-handling rxjs angular2-services

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

docker-compose 失败时如何查看错误日志

我有一个启动 entrypoint.sh 脚本的 docker 镜像

此脚本检查项目是否配置良好

如果一切正确,容器将启动,否则我收到此错误:

echo "Danger! bla bla bla"
exit 1000
Run Code Online (Sandbox Code Playgroud)

现在,如果我以这种模式启动容器:

docker-compose up
Run Code Online (Sandbox Code Playgroud)

我正确地看到错误:

Danger! bla bla bla
Run Code Online (Sandbox Code Playgroud)

但我需要以守护进程模式启动容器:

docker-compose up -d
Run Code Online (Sandbox Code Playgroud)

如何仅在出错时显示日志?

error-handling docker-compose

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

如何使用vue js @Component与typescript 2.6.1?

我创建了一个小组件:

import Vue from 'vue';
import Component from 'vue-class-component';
import { Inject, Model, Prop, Watch } from 'vue-property-decorator';

@Component({
    template: require('./home.html'),
})
export class HomeComponent extends Vue {
    name: string = 'User';
}
Run Code Online (Sandbox Code Playgroud)

我可以使用typescript@2.5.3毫无问题地编译项目

但如果我尝试使用typescript@2.6.1我有这个错误:

[at-loader] ./src/components/home/home.ts:8:2中的错误

TS2345: Argument of type 'typeof HomeComponent' is not assignable to parameter of type 'VueClass<Vue>'.
Type 'typeof HomeComponent' is not assignable to type 'new (...args: any[]) => Vue'.
  Type 'HomeComponent' is not assignable to type 'Vue'.
    Types of property '$options' are incompatible.
      Type 'ComponentOptions<HomeComponent, …
Run Code Online (Sandbox Code Playgroud)

tsconfig typescript2.0 vuejs2

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

Vue JS 2如何从生产中删除Console.log

在IE中,仅在F12调试模式下定义控制台。所以我正在寻找一种方便的方法来管理Vue的编译

我希望能够在代码内部编写console.log

alert('a');
console.log('only in develope mode');
alert('b');
Run Code Online (Sandbox Code Playgroud)

如果我在生产模式下编译,则命令控制台必须消失

alert('a');
alert('b');
Run Code Online (Sandbox Code Playgroud)

如果我在开发模式下工作,则必须出现命令控制台

alert('a');
console.log('only in develope mode');
alert('b');
Run Code Online (Sandbox Code Playgroud)

在vue js中,我有2种webpack配置:一种用于开发,另一种用于生产

这可能是这样吗?

我无法正确配置webpack文件,但我认为是这样的:

const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
module.exports.plugins = (module.exports.plugins || []).concat([
 new UglifyJsPlugin({
  sourceMap: true,
  compress: {
    drop_console: true,
    warnings: false
  },
  comments: false
 }),
])
Run Code Online (Sandbox Code Playgroud)

compilation console.log webpack vuejs2

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

如何在Express中使用dialogflow-fulfillment-nodejs

我想在Express中使用dialogflow实现库

这是我的代码:

import * as express from 'express';
import * as bodyParser from 'body-parser';
import * as dialogflowController from './controllers/dialogflow';

const app: express.Application = express();
app.use(bodyParser.json());
app.post('/echo', dialogflowController.doActions);
const http = require('http');
const httpServer = http.createServer(app);
httpServer.listen(80, function () { // ascolta sulla porta 80 per comando: ngrok http 80
  console.log('HTTP Started!');
});



// dialogflowController controller unit

import { Request, Response, NextFunction } from 'express';
const { WebhookClient, Card, Suggestion } = require('dialogflow-fulfillment');


export let doActions = (req: Request, res: …
Run Code Online (Sandbox Code Playgroud)

node.js express dialogflow-es

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

元素隐式包含“ any”类型,因为没有索引签名分配给类型“ {}”

对于Express应用程序,我有以下打字稿代码:

for (var propertyName in req.body) {
    console.log(req.body[propertyName]);
}
Run Code Online (Sandbox Code Playgroud)

正常工作

现在,我在另一个打字稿应用程序中重复使用,但是出现了这个错误:

[ts]不包含任何内容的隐含元素,但不包含任何名称的索引。

[ts]元素隐式包含“ any”类型,因为没有索引签名分配给类型“ {}”。

我不明白这个错误

错误在

req.body[propertyName]
Run Code Online (Sandbox Code Playgroud)

如何将签名分配给索引?

typescript

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