小编net*_*djw的帖子

我可以在canvas元素中绘制一个表吗?

是否有任何方法(插件,工作解决方案等)将元素绘制HTML table<canvas>元素?

我有一个格式丰富的html表(使用CSS),我想将其保存为图像(PNG,SVG或GIF)使用jQuery.......或者如果有任何最简单的方法,我正在听它.

jquery html5 image-processing html5-canvas

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

使用Google Direction API,Access-Control-Allow-Origin不允许使用原始网址

我知道这个问题已经被问到并回答了,但它对我没有帮助.

这是我的jQuery代码:

var gmapsurl = 'http://maps.googleapis.com/maps/api/distancematrix/json?'+
                            'origins='+addr_origin+
                            '&destinations='+addr_destination+
                            '&mode=driving&language=hu&units=metric'+
                            '&key='+mykey+
                            '&sensor=false';
$.getJSON(gmapsurl, function(data) {
    alert( 'OK' );
});
Run Code Online (Sandbox Code Playgroud)

现在我Origin (my site url) is not allowed by Access-Control-Allow-Origin.在浏览器中收到错误消息.但是如果我将这个url直接写入浏览器,那么我会得到一个JSON结构.

我怎样才能解决这个问题?

jquery access-control google-maps-api-3

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

html中的自动列文本换行

有没有办法用CSS 将文本换行到HTML中的两个或更多列?

我有连续的文字p标签只有这样:

<div id="needtowrap">
    <p>Lorem ipsum dolor sit amet, ...</p>
    <p>Nulla ullamcorper diam arcu, ...</p>
    <p>In libero diam, facilisis quis urna nec, ...</p>
    <p>Sed varius et mi quis dictum. ...</p>
</div>
Run Code Online (Sandbox Code Playgroud)

我想把这个文本分成两列50%的文本,比如Microsoft Word或LibreOffice等.

有可能的?

html css html5 text css3

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

Perl`使用qw`或从pm文件导入子例程

我有一个perl模块.pm文件包含我的子程序,它看起来像这样:

package test;
use strict;
use vars qw($VERSION @ISA @EXPORT $ERROR $NAME);
require Exporter;
@ISA  = qw(Exporter);
@EXPORT = (
    sub1
    sub2
    err1
    err2
);
#...etc...
Run Code Online (Sandbox Code Playgroud)

现在我有一个pl文件,需要导入子例程,但不是每个子例程,只有它们在配置列表中.例如:

@subs = ('sub1', 'sub2'); # need to load sub1 & sub2, but do not load err1 & err2
Run Code Online (Sandbox Code Playgroud)

要么

@subs = ('sub1', 'err1'); # need to load sub1 & err1, but do not load sub2 & err2
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

我试图这样做,但没有工作:

my @subs = ('sub1', 'sub2');
use test @subs;
Run Code Online (Sandbox Code Playgroud)

有没有办法只加载所需的功能?所需要的是从SQL或配置文件或任何其他方式读取...

perl perl-module

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

如何在Firefox或IE/Edge中以Chrome和.jpg显示.webp?

是否有任何工作示例.webp在Chrome中显示格式文件,.jpg在Firefox和IE/Edge中显示不同的格式文件?

我现在用户这个CSS代码:

#bgbox {
    background-imgage: url('../img/bg.webp');
}
Run Code Online (Sandbox Code Playgroud)

有没有这样的-moz-background-image东西?

css firefox google-chrome css3 microsoft-edge

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

如何从 TypeScript 中的泛型类型创建实例?

我有一个可以处理本地存储中的数据的服务,还有另一个可以处理远程 API 查询的服务。当我定义数据模型时,我会给出模型是否使用本地存储。

现在我尝试构建一个代理服务,它可以根据模型定义决定从本地存储还是从远程 API 请求数据。

现在我有这个代码:

export class ProxyService<T> {
  public type: new () => T;
  private emptyModel: T = new this.type();
  private localstorageService: LocalstorageDataService<T> =
    new LocalstorageDataService(this.type, this.httpClient);
  private remoteDataService: RemoteDataService<T> = new RemoteDataService(this.type, this.httpClient);

  constructor(
    private httpClient: HttpClient,
  ) { }

  getOne(id: number): Observable<T> {
    if (this.emptyModel.use_localstorage) {
      return of(this.localstorageService.findById(id));
    } else {
      return this.remoteDataService.getOne(id).pipe(map((result: T) => result));
    }
  }

  // other proxy functions are here...
}
Run Code Online (Sandbox Code Playgroud)

但我收到这个错误:

Error: Uncaught (in promise): TypeError: this.type is not a …
Run Code Online (Sandbox Code Playgroud)

typescript typescript-generics

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

如何使用 TypeScript 编译器 API 向 TypeScript 类添加新属性?

我尝试向我的文件添加新属性awesome.model.ts

原来的内容是这样的:

import { TagInterface, TagUIFieldsInterface } from './tag.interface';

export class Tag implements TagInterface {
  readonly api_endpoint = '/tag';
  id: ID;
  name: string;

  fields: FieldContainerInterface<TagUIFieldsInterface> = {
    // ...
  };

  init(data?: any): TagInterface {
    // ...
  }
}
Run Code Online (Sandbox Code Playgroud)

我想在属性行color_code: string;之后添加一个新属性。name看起来像这样:

import { TagInterface, TagUIFieldsInterface } from './tag.interface';

export class Tag implements TagInterface {
  readonly api_endpoint = '/tag';
  id: ID;
  name: string;
  color_code: string;

  fields: FieldContainerInterface<TagUIFieldsInterface> = {
    // ...
  };

  init(data?: any): TagInterface { …
Run Code Online (Sandbox Code Playgroud)

typescript typescript-compiler-api

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

如何使用 RxJS 跳过可观察值的第一个值?

在我的 Angular 项目中,我使用这个组件来代表表单中的输入字段。目标是在用户更改输入字段的值时即时保存它:

export class SettingInputComponent implements OnInit, OnDestroy {
  @Input() model: SettingInterface;

  private subscriptions: Subscription = new Subscription();

  private appDataService: AppDataServiceInterface<SettingInterface> =
    new AppDataFactoryService<SettingInterface>().get(Setting);

  private value$: BehaviorSubject<any> = new BehaviorSubject(this.model.value);

  constructor() { }

  ngOnInit(): void {
    this.subscriptions.add(this.saveSetting().subscribe());
  }

  ngOnDestroy(): void {
    this.subscriptions.unsubscribe();
  }

  emitToSave(): void {
    this.value$.next(this.model.value);
  }

  private saveSetting(): Observable<any> {
    return this.value$.pipe(
      debounceTime(500),

      distinctUntilChanged(),

      switchMap(() => this.appDataService.save(this.model)
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

HTML:

<third-party-input
  type="text"
  [value]="model.value"
  (change)="emitToSave()"
></third-party-input>
Run Code Online (Sandbox Code Playgroud)

问题是初始化saveSetting()可观察对象的组件何时会触发。我想避免这种行为,并且仅当用户更改模型的值属性时才触发。

如何避免在初始化时触发并仅在用户更改值时触发?

rxjs angular

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

如何在Perl中启动while循环之前打印?

我有这个代码Perl:

print "Processing ... ";
while ( some condition ) {
    # do something over than 10 minutes
}
print "OK\n";
Run Code Online (Sandbox Code Playgroud)

现在我在while循环结束返回第一个打印件.

如何启动while循环之前打印messeage ?

printing perl while-loop

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

发送电子邮件时 Laravel 8 刀片模板中的“未定义变量”

在我的 Laravel 8 项目中,我尝试发送 HTML 电子邮件,但Undefined variable出现错误。

我的控制器中有此代码:

// here the $client has a model value
Mail::to($client)->send(new ClientCreated($client));
Run Code Online (Sandbox Code Playgroud)

在我的app/Mail/ClientCreated.php文件中:

<?php

namespace App\Mail;

use App\Client;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class ClientCreated extends Mailable
{
    use Queueable, SerializesModels;

    private $client;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct(Client $client)
    {
        $this->client = $client;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        // …
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-blade

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