小编met*_*lah的帖子

Powershell - 如果没有Excel进程,添加catch以获取

有没有办法只添加一个if/else catch

$excelId = get-process excel | %{$_.Id} | ?{$before -notcontains $_}
Run Code Online (Sandbox Code Playgroud)

如果没有excel进程在运行?例如,如果Excel正在运行,那么get-process id,如果没有,则忽略它.

Get-Process:找不到名为"excel"的进程.验证进程名称并再次调用cmdlet.在run.ps1:3 char:24 + $ before = @(get-process <<<< excel |%{$ _.Id})+ CategoryInfo:ObjectNotFound:(excel:String)[Get-Process],ProcessCommandException + FullyQualifiedErrorId:NoProcessFoundForGivenName,Microsoft.PowerShell.Commands.GetProcessCommand

我的代码的第3-5行如下:

$before = @(get-process excel | %{$_.Id} ) 
$excel=new-object -com excel.application
$excelId = get-process excel | %{$_.Id} | ?{$before -notcontains $_}
Run Code Online (Sandbox Code Playgroud)

com excel powershell

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

将航点添加到Google Distance Matrix中以确定里程

我在这里使用Google的Map Distance Matrix 创建了一个简单的jsfiddle,以确定2点之间的里程。效果很好,但后来我有兴趣确定2分以上的里程。但是,由于我认为我没有正确实现它,因此我无法做到这一点。有谁知道如何将路标添加到Google的距离矩阵中,以便确定驾车之间的最佳路线/里程?例如,如果我想从一开始The Underpass, Birmingham8 Shandon Close, Birmingham通过一堆其他的地方。我的代码已包含在下面:

var origin = "The Underpass, Marston Green, Birmingham, West Midlands B40 1PA, UK",
    destinations = ["8 Shandon Close, Birmingham, West Midlands B32 3XB, UK","2 The Osiers, Elford, Tamworth, Staffordshire B79 9DG, UK","170 Bells Lane, Birmingham, West Midlands B14 5QA, UK","246 Long Acre, Birmingham, West Midlands B7 5JP, UK","28 Cuthbert Road, Birmingham, West Midlands B18 4AG, UK"]
    service = new google.maps.DistanceMatrixService();

service.getDistanceMatrix({
    origins: [origin], …
Run Code Online (Sandbox Code Playgroud)

javascript google-maps

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

检查List <Map <String,String >>中是否存在String

如果我有这样的List<Map<String, String>>对象tempNameMapList:

0
   0 = "id" -> 101
   1 = "name" -> jonathan
1
   0 = "id" -> 102
   1 = "name" -> sam
2
   0 = "id" -> 103
   1 = "name" -> tim
Run Code Online (Sandbox Code Playgroud)

还有一个String对象String name = "tim",如何快速检查它是否存在tempNameMapList

java java-8

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

导航栏组件上的静态成员不可访问错误

我不断收到以下错误:Static member is not accessible此时:

<code> <nav * ngIf =“!authService.isLoggedIn” ...> </ nav> </ code>

验证服务

export class AuthService {
  public static get isLoggedIn() {
    const user = JSON.parse(localStorage.getItem('user'));
    return (user !== null &&
      ((user.emailVerified === false && user.providerData[0].providerId === 'facebook.com') ||
        ((user.emailVerified !== false))));
  }
}
Run Code Online (Sandbox Code Playgroud)

navbar.component.html

<nav *ngIf="!authService.isLoggedIn" class="navbar navbar-expand-lg navbar-dark" data-navbar="smart"></nav>
Run Code Online (Sandbox Code Playgroud)

navbar.component.ts

@Component({
  selector: 'app-navbar',
  templateUrl: './navbar.component.html'
})
export class NavbarComponent implements OnInit {
  constructor(
    private authService: AuthService
  ) {}
}
Run Code Online (Sandbox Code Playgroud)

我该如何解决?

angular

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

Angular9 - 检查 Firebase 用户当前是否已登录

检查用户当前是否登录 Angular 9 的最佳方法是什么?最初,我会这样做:

  constructor(
    public afAuth: AngularFireAuth,
    private logger: NGXLogger
  ) {
    this.afAuth.authState.subscribe((result) => {
      if (result) {
        this.user = result;
      }
    });
  }

  public isLoggedIn(): boolean {
    const user = this.afAuth.currentUser;
    return !!user;
  }
Run Code Online (Sandbox Code Playgroud)

然后以这种方式从我的组件中调用它:

    isLoggedIn(): boolean {
      return this.authService.isLoggedIn();
    }

    <button
      *ngIf="!isLoggedIn()"
      class="btn btn-glass btn-primary"
      id="builder-header-create-account"
      type="button"
    >
      Sign Up
    </button>
Run Code Online (Sandbox Code Playgroud)

但升级到 Angular 9 后,上述代码导致我的 UI 挂起。修复它的最佳方法是什么?

firebase angular

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

Tailwind - 保持标题和左/右侧边栏粘在滚动上

如何使标题、左/右侧边栏粘在滚动条上(在桌面上,而不是移动设备上)?

它似乎不适用于固定或粘性类,我在这里发布了一个示例: https: //play.tai​​lwindcss.com/Bj68nUJj1C

<!-- Background color split screen for large screens -->
<div class="fixed top-0 left-0 h-full w-1/2 bg-white" aria-hidden="true"></div>
<div class="fixed top-0 right-0 h-full w-1/2 bg-gray-50" aria-hidden="true"></div>
<div class="relative flex min-h-screen flex-col">
  <!-- Navbar -->
  <nav class="flex-shrink-0 bg-indigo-600">
    <div class="mx-auto max-w-7xl px-2 sm:px-4 lg:px-8">
      <div class="relative flex h-16 items-center justify-between">
        <!-- Logo section -->
        <div class="flex items-center px-2 lg:px-0 xl:w-64">
          <div class="flex-shrink-0">
            <img class="h-8 w-auto" src="https://tailwindui.com/img/logos/workflow-mark.svg?color=indigo&shade=300" alt="Workflow" />
          </div>
        </div>

        <!-- Search section -->
        <div class="flex flex-1 …
Run Code Online (Sandbox Code Playgroud)

css tailwind-css tailwind-ui

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

计算模式在字符串中出现的次数

使用JS计算字符串在字符串中出现的次数的最佳方法是什么?

例如:

count("fat math cat", "at") returns 3
Run Code Online (Sandbox Code Playgroud)

javascript string

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

使用Javascript生成动态数据

鉴于我有一组字母字符:

var qwerty = [['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p'], ['a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l'], ['z', 'x', 'c', 'v', 'b', 'n', 'm']];
Run Code Online (Sandbox Code Playgroud)

如何在使用JS的传统键盘上将它们呈现在三行中,而不是采用这样的方式:

<input type='button' value='Q' id='bt1'/>
<input type='button' value='W' id='bt2'/>
<input type='button' value='E' id='bt3'/>
<input type='button' value='R' id='bt4'/>
<input type='button' value='T' id='bt5'/>
<input type='button' value='Y' id='bt5'/>
<input type='button' value='U' id='bt7'/>
<input type='button' value='I' id='bt8'/>
<input type='button' value='O' id='bt9'/>
<input type='button' value='P' id='bt10'/>
<br>
<input type='button' value='A' id='bt11'/>
<input type='button' value='S' id='bt12'/> …
Run Code Online (Sandbox Code Playgroud)

javascript

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

在两个离子形式元素之间创建换行符

如何在以下 Ionic 表单元素之间强制换行?

目前它看起来像这样:

在此处输入图片说明

我希望它看起来像这样:

在此处输入图片说明

到目前为止的代码:

    <div class="item item-input-inset">
        <label class="item-input-wrapper">
            <i class="icon ion-ios-search placeholder-icon"></i>
            <input type="search" placeholder="What are you looking for?">
        </label>
        <label class="item-input-wrapper">
            <i class="icon ion-ios-search placeholder-icon"></i>
            <input type="search" placeholder="Current Location">
        </label>
    </div>
Run Code Online (Sandbox Code Playgroud)

在这里小提琴:http : //jsfiddle.net/o5z6d8z0/

html css

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

将从 URL 提取的图像转换为 base64

每当用户通过 Facebook 登录时,我都会获取他们的 Facebook 个人资料图片。我想将图像从 URL 转换为 Base 64。在确保用户仍然可以在视图(home.view)中看到他们的个人资料图片的同时,最好的方法是什么?目前,我直接引用 URL。

到目前为止,这是我的代码:

facebook.service.js

function FacebookService($http, config) {
      this.getUserPicture = function(userId, token) {
      return $http({
        method: 'GET',
        url: 'https://graph.facebook.com/' + userId + '/picture?type=large&redirect=false'
      })
    }
  }
Run Code Online (Sandbox Code Playgroud)

home.controller.js

function HomeController($scope, $cordovaNativeStorage, FacebookService, $ionicLoading) {
  if (window.cordova) {
    // Get Facebook access token
    $cordovaNativeStorage.getItem("facebookAccessToken").then(function(value) {
      $scope.facebookAccessToken = value

      // Get Facebook user picture (currently stored as a URL, would want to store it as a base 64 string which can be displayed as an …
Run Code Online (Sandbox Code Playgroud)

javascript facebook angularjs cordova ionic-framework

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