小编Ric*_*cha的帖子

Jasmine:匹配器不同于 undefined 和 null (!= undefined 和 != null)

我注意到,如果我编写expect expect(null).toBeDefined();,测试就会通过,因为茉莉花认为null是一个已定义但没有任何值的对象。

我的问题是,是否有一个匹配器可以同时评估对象undefined是否不同。null

unit-testing jasmine

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

如何向根组件dom元素添加样式(角度选择器组件)

我有以下组件:

// Typescript
@Component({
    selector: 'form-button',
    templateUrl: './form-button.component.html',
    styleUrls: ['./form-button.component.scss']
})
export class FormButtonComponent {}

//form-button.component.html
<div class="form-button-wrapper">
    <div class="content"></div>
</div>

//form-button.component.scss
.form-button-wrapper {
    width: 100%;
    height: 100%
}
Run Code Online (Sandbox Code Playgroud)

在 html 中,将如下所示:

<head>...</head>
<body>
    ....
    <form-button>
         <div class="form-button-wrapper">
             <div class="content"></div>
         </div>
    </form-button>
    ....
</body>
Run Code Online (Sandbox Code Playgroud)

我希望 t 定义宽度和重量,<form-button>而不是在 中<div class="form-button-wrapper">

我怎样才能做到这一点?

javascript css sass typescript angular

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

[Tooltipster Plugin] - 知道div是否已经有tooltipster

我正在使用这个插件http://iamceege.github.io/tooltipster/.

有可能知道HTML是否已经初始化了工具提示器?

我想知道,因为有时我需要更改工具提示的文本,为此,我需要销毁工具提示器,更改HTML对象的属性标题,然后再次初始化.像这样:

$(this).tooltipster('destroy').attr("title", data.fields[i].value).tooltipster();
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery tooltipster

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

在MVC控制器外部使用Controller.Content c#

我正在使用静态方法创建一个静态类,以帮助控制器完成他们的工作.构建应用程序时,我收到以下错误:

System.Web.Mvc.Controller.Content(string)由于其保护级别错误40' '无法访问

知道如何解决这个问题吗?

注意:这是ac#mvc aplication

public static ActionResult GetAlbumJSON(AlbumVO album)
{
    return Controller.Content(
        JsonConvert.SerializeObject(new
        {
            max_car = @ABookClient.maxCharsProjecName,
            trans_img = @ABookClient.Transparent_Image,
            show_description = @ABookClient.Show_Product_Description,
            product_type = "Album",
            obj = CreateObjAlbumVO(album),
        })
    );
}
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc

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

错误:rxjs/operator/map没有导出的成员'map'

我正在从角度5迁移到角度6.当我进行npm运行构建时,我是向控制台抛出以下错误:

错误TS2305:模块"'C:/PrjNET/Elevation3/FW/4.00/Mainline/Framework/Development/Client/ElevationJS/ngcore/.tmp/node_modules/rxjs/operator/map’"不具有出口构件"地图".

我输入map如下:

import { map} from 'rxjs/operator/map';
Run Code Online (Sandbox Code Playgroud)

谁知道如何解决这个问题?

angular6 rxjs6

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

TensorflowJS:错误: model.execute(dict) 中提供的 dict['images'] 的形状必须为 [-1,224,224,3],但为 [400,600,1]

我正在使用谷歌的mobilenet神经网络对图像进行分类。我正在使用 Angular 6 + TensorFlow.js 构建我的图像分类器应用程序。

我尝试按照tfjs-converter 库自述文件提供的步骤进行操作,并得出以下代码:

import * as tf from '@tensorflow/tfjs';
import { FrozenModel } from '@tensorflow/tfjs';

export class NeuralNetwork {
    private MODEL_PATH: string = 'http://localhost:4200/assets/model/tensorflowjs_model.pb';
    private WEIGHTS_PATH: string = 'http://localhost:4200/assets/model/weights_manifest.json';
    constructor(){}
    async loadModel() {
        const localModel: FrozenModel = (await tf.loadFrozenModel(this.MODEL_PATH, this.WEIGHTS_PATH));
        let image: any = document.getElementById('cat');

        let pixels =  tf.fromPixels(image, 1);
        let result = localModel.predict(pixels);
        
    }
    async predict(){
        let image: any = document.getElementById('cat');
        debugger;
        this.model.execute({input: tf.fromPixels(image)});
    }
    
}
Run Code Online (Sandbox Code Playgroud)

图像 HTML 元素:

<img …
Run Code Online (Sandbox Code Playgroud)

typescript tensorflow angular tensorflow.js

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

错误 TS2688 中的错误:找不到“jest”的类型定义文件

我有一个 angular 6 应用程序,我正在使用 karma + jasmine 来运行我的测试。但是当我运行时,ng test我收到以下错误:

错误 TS2688 中的错误:找不到“jest”的类型定义文件。

有谁知道如何解决这个问题?

jasmine karma-runner angular-cli angular angular6

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

DEPRECATION:','不建议在Env上直接设置specFilter,请在configure中使用specFilter选项'

我在我的angular 6应用程序中使用了业力+茉莉花,并且收到以下警告:

DEPRECATION:','不建议在Env上直接设置specFilter,请在configure中使用specFilter选项'

我应该怎么做才能解决此警告?

javascript jasmine typescript karma-runner angular

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

在 Typescript 私有属性中使用 SinonJS 时报告为缺少

我正在尝试使用 stub 类实例,sinon.createStubInstance但我收到一个错误,指出缺少私有成员变量。当然我也不能明确设置它,因为它是一个私有成员。

示例类:

class Foo {
  private readonly bar: string;

  constructor(bar: string) {
    this.bar = bar;
  }
}

class Parent {
  foos: Foo[];

  constructor(foos: Foo[]) {
    this.foos = foos;
  }
}
Run Code Online (Sandbox Code Playgroud)

在测试中,我正在编写一个beforeEach块:

beforeEach(function () {
  const stubFoo = sinon.createStubInstance(Foo);

  const stubParent = sinon.createStubInstance(Parent);
  stubParent.foos = [stubFoo]; // Tslint error here
});
Run Code Online (Sandbox Code Playgroud)

Tslint 错误是:

“SinonStubbedInstance”类型中缺少属性“bar”,但“Foo”类型中需要

作为记录,我使用的是 Typescript v3.0.3 和 Sinon v7.4.1。

stub sinon typescript

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

使用github操作部署firebase云函数

我正在尝试使用 github 操作部署我的 firebase 云功能应用程序:

name: Deploy

'on':
  push:
    branches:
      - main

jobs:
  deploy_to_production:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: install dependencies
        run: cd functions/ && npm install
      - name: deploy to production
        uses: w9jds/firebase-action@master
        with:
          args: deploy --only functions
        env:
          FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
          
Run Code Online (Sandbox Code Playgroud)

“部署到生产”步骤未成功。我激活调试模式,但实际上没有收到任何有用的信息:

##[debug]Evaluating: secrets.FIREBASE_TOKEN
##[debug]Evaluating Index:
##[debug]..Evaluating secrets:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'FIREBASE_TOKEN'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Evaluating condition for step: 'deploy to production'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: …
Run Code Online (Sandbox Code Playgroud)

github firebase google-cloud-functions github-actions

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