小编sr9*_*yar的帖子

角度错误 - 通用类型“ModuleWithProviders<T>”需要 1 个类型参数

从 Angular 版本 8 升级到 10 后。

运行 - ng serve 命令给我错误 -

node_modules/ngx-tree-select/src/module.d.ts:11:56 中的错误 - 错误 TS2314:通用类型“ModuleWithProviders”需要 1 个类型参数。

11 static forRoot(options: TreeSelectDefaultOptions): ModuleWithProviders; ~~~~~~~~~~~~~~~~~~~

这是我的文件 - front/webapp/node_modules/ngx-tree-select/src/module.d.ts

import { ModuleWithProviders } from '@angular/core';
import { TreeSelectDefaultOptions } from './models/tree-select-default-options';
import * as ?ngcc0 from '@angular/core';
import * as ?ngcc1 from './components/tree-select.component';
import * as ?ngcc2 from './components/tree-select-item.component';
import * as ?ngcc3 from './directives/off-click.directive';
import * as ?ngcc4 from './pipes/item.pipe';
import * as ?ngcc5 from '@angular/common';
import * as …
Run Code Online (Sandbox Code Playgroud)

angular

38
推荐指数
6
解决办法
4万
查看次数

尝试从主机连接到 mysql docker 容器时出现“读取初始通信数据包”错误

我希望能够连接到我的 docker 容器,就像 MySQL 服务器安装在我的本地计算机上一样。我测试我的连接:

mysql -u root -proot -h 127.0.0.1 -P 3306 --protocol=tcp
Run Code Online (Sandbox Code Playgroud)

如果我使用docker创建一个容器,我可以成功地做到这一点。像这样:

docker run --name some-mysql-standalone -p 127.0.0.1:3306:3306 -e MYSQL_ROOT_PASSWORD=root -d mysql:5.7.29
Run Code Online (Sandbox Code Playgroud)

如果我在 docker-compose 中使用容器作为服务,则会收到错误:

ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 2
Run Code Online (Sandbox Code Playgroud)

MySQL 服务器正在容器内运行,我可以访问它。

我的 docker 撰写片段:

version: '2'

services:

    mysql:

        image: mysql:5.7.29
        container_name: some_mysql
        restart: unless-stopped

        volumes:
            - ./mysql/data:/var/lib/mysql
            - ./mysql/init:/docker-entrypoint-initdb.d

        ports:
            - 3306:3306

        environment:
            MYSQL_DATABASE: some_mysql
            MYSQL_USER: root
            MYSQL_PASSWORD: root
            MYSQL_ROOT_PASSWORD: root
Run Code Online (Sandbox Code Playgroud)

有趣的是,我已经使用它docker-compose.yml有一段时间了,没有任何问题。我不太确定我的环境发生了什么变化导致它停止工作。

如何使 …

mysql docker docker-compose

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

无法使用凭证存储登录 Ubuntu 18 上的 Docker

我无法使用 登录 docker docker login

我正在执行:

sudo docker login --username USERNAME --password PASSWORD
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

Error saving credentials: error storing credentials - err: exec: 
"docker-credential-pass": executable file not found in $PATH, out: ``
Run Code Online (Sandbox Code Playgroud)

我尝试搜索类似的错误,但没有真正找到任何相关的内容。

我在用着:

Ubuntu 18.10。

Docker 版本 18.06.0-ce,内部版本 0ffa825。

为什么会发生这种情况?

ubuntu docker

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

node_modules/preact/src/jsx.d.ts:2145:22 - 错误 TS2304:找不到名称“SVGSetElement”

自过去两天以来,我遇到了此构建错误(Angular 应用程序)。

Error: node_modules/preact/src/jsx.d.ts:2138:24 - error TS2304: Cannot find name 'SVGMPathElement'. 2138 mpath: SVGAttributes<SVGMPathElement>;

node_modules/preact/src/jsx.d.ts:2145:22 - error TS2304: Cannot find name 'SVGSetElement'. 2145 set: SVGAttributes<SVGSetElement>;

在此输入图像描述

我尝试了很多方法来解决,并遵循了许多与错误2304模块未找到相关的答案。但是,他们都没有工作。Node 和 Angular 版本分别为 16.16.0 和 11.2.14。有谁遇到过这个错误或者有解决方案的请回复。任何回应将不胜感激。谢谢你!

尝试将 preact 添加到 package.json 以及 stackoverflow 中给出的其他一些方法

node.js typescript angular-cli preact angular

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

Laravel 5.4:如何遍历请求数组?

我的请求数据代表一系列新项目和现有项目.我正在尝试通过此数组来更新和创建项目.

这是我检索数组的方法:

$userInput = $request->all();
foreach( $userInput['items'] as $key=>&$item){
Run Code Online (Sandbox Code Playgroud)

稍后在代码中我更新了一个现有项目:

$updateItem = Item::find($item['id']);
$updateItem->number = $item['number'];
$updateItem->save();
Run Code Online (Sandbox Code Playgroud)

$item['number']似乎包含以前更新的旧输入,而不是我上次输入的值.

如何在Laravel中循环请求数据?

这是我运行它的整个代码(想摆脱混乱):

$userInput = $request->all();
// checking $userInput here
// I can see the new value in the array

foreach( $userInput['items'] as $key=>$item){
  if($item['delete'] == 1) {
    Item::where('order_id',$order->id)
      ->where('id',$item['id'])
      ->delete();
  } else {
    if(empty($item['id'])) {
    } else {
      $updateItem = Item::find($item['id']);
      $updateItem->number = $item['id'];
      $updateItem->save();
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

这是来自html的输入(只是为了显示我也检查了表单,数据来得很好):

<input id="basicItemNumber-31" class="form-control" name="items[31][number]" placeholder="Unique number" value="31" type="text">
Run Code Online (Sandbox Code Playgroud)

php arrays laravel laravel-5 laravel-5.4

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

从 .env 设置 Angular 6 环境变量

有一个使用环境变量的 angular 6 项目 ./project/src/environments/environment.prod.ts

export const environment = {
  production: true,
  testVar: 'gg',
};
Run Code Online (Sandbox Code Playgroud)

这个项目的后端在一个.env文件中也有 env 变量,所以很多变量重复了 angular env 变量。有类似的东西会很好

export const environment = {
  production: true,
  testVar: process.env.TEST_VAR
};
Run Code Online (Sandbox Code Playgroud)

,所以我不必复制变量。

IE

我想从.env文件中解析变量,并在服务器上的打字稿编译期间将它们的值分配给角度环境变量。

如何才能做到这一点?也许用webpack?

更新

一些澄清。我的 .env 文件不包含 json。它看起来像这样:

TEST_VAR=1
Run Code Online (Sandbox Code Playgroud)

更新

由于ng eject 不适用于 Angular 6,我似乎无法侵入 webpack 配置。这里好像死路一条。

弹出

概述

暂时禁用。

弹出您的应用程序并输出正确的 webpack 配置和脚本。

javascript angular angular6

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

获取私人视频的 Vimeo 缩略图

我有一个 Vimeo 私人视频网址列表 ( https://player.vimeo.com/video/1234567890),我想在我的页面上显示为缩略图。我找不到工作的方法来做到这一点。

任何基于此的解决方案http://vimeo.com/api/v2/video/{id}都已经死了。

像这样的事情https://i.vimeocdn.com/video/1234567890.jpg会返回错误的图像。

有没有办法在未经授权的情况下根据视频 ID 获取图像缩略图 url?

更新

就我而言,我设法thumbnail_url通过查询获得

GET https://vimeo.com/api/oembed.json?url=https://player.vimeo.com/video/{id}

vimeo vimeo-api

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

Webpack: bundle multiple vendor css in one separate file?

我想用 webpack 3.8 将几个标准库捆绑成两个文件 bundle.js 和 bundle.css

这是我的 webpack.config.js:

const webpack = require('webpack');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const path = require("path");

module.exports = {
  entry: {
    'vendor': [
      'jquery',
      'popper.js',
      'bootstrap',
    ],

  },

    output: {
    path: path.resolve(__dirname, 'public/js'),
    filename: 'bundle.js'
  },

  module: {
              rules:[
                    {
                    test: /\.css$/,
                    use: ExtractTextPlugin.extract({
                      fallback: "style-loader",
                      use: "css-loader"
                    })
                  }
                ],


  },

  plugins: [

    new webpack.optimize.UglifyJsPlugin({
      uglifyOptions: {
        compress: true 
      }
    }),

    new ExtractTextPlugin("styles.css"),

  ]
};
Run Code Online (Sandbox Code Playgroud)

运行 webpack 后,我只得到 bundle.js 文件:

    Asset    Size  Chunks                    Chunk …
Run Code Online (Sandbox Code Playgroud)

webpack webpack-style-loader

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

确认条带的付款意图时,代码= 50“无此付款意图”

使用此方法确认付款意向时出现以下错误 STPAPIClient.shared().confirmPaymentIntent()

错误Domain = com.stripe.lib代码= 50“没有这样的付款意图:pi_1ElaQpFSNNCQ7y59” UserInfo = {com.stripe.lib:ErrorMessageKey =没有这样的付款意图:pi_1ElaQpFSNNCQ7y59,com.stripe.lib:StripeErrorCodeKey = resource_missing,com。 :StripeErrorTypeKey = invalid_request_error,com.stripe.lib:ErrorParameterKey = intent,NSLocalizedDescription =否这种付款方式:pi_1ElaQpFSNNCQ7y59}

我正在执行的代码:

STPAPIClient.shared().confirmPaymentIntent(with: paymentIntentParams, completion: { (paymentIntent, error) in

if let error = error {

    // handle error

} else if let paymentIntent = paymentIntent {

    // see below to handle the confirmed PaymentIntent

    if paymentIntent.status == .requiresAction {

        guard let redirectContext = STPRedirectContext(paymentIntent: paymentIntent, completion: { clientSecret, redirectError in

            // Fetch the latest status of the Payment Intent if necessary
            STPAPIClient.shared().retrievePaymentIntent(withClientSecret: clientSecret) …
Run Code Online (Sandbox Code Playgroud)

payment payment-gateway stripe-payments swift

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

Laravel 资源策略始终为 false

我试图允许用户在 Laravel 5.4 中查看他们自己的个人资料。

用户策略.php

public function view(User $authUser, $user)
{ 
 return true;
}
Run Code Online (Sandbox Code Playgroud)

在 AuthServiceProvider.php 中注册的策略

protected $policies = [
    App\Task::class => App\Policies\TaskPolicy::class,
    App\User::class => App\Policies\UserPolicy::class
];
Run Code Online (Sandbox Code Playgroud)

路线

Route::group(['middleware' => 'auth'], function() {
  Route::resource('user', 'UserController');
} );
Run Code Online (Sandbox Code Playgroud)

刀片模板

@can ( 'view', $user )
// yes
@else
// no
@endcan
Run Code Online (Sandbox Code Playgroud)

用户控制器.php

public function profile()
{
    return $this->show(Auth::user()->id);
}
public function show($id)
{
    $user = User::find($id);
    return view('user.show', array( 'user'=>$user,'data'=>$this->data ) );
}
Run Code Online (Sandbox Code Playgroud)

返回总是“假”。从控制器调用策略也是如此。我哪里出错了?

php laravel laravel-5

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