小编Fun*_*kel的帖子

使用RESTSHARP时,API返回错误

当使用RestSharp调用API时,我收到此错误:

底层连接已关闭:发送时发生意外错误.

我已经验证我的客户端ID,密码,用户名和密码是否正确.我能够在没有PowerShell问题的情况下做到这一点.

public string GetTokenForBrightIdea()
{
    RestClient restclient = new RestClient(_uri);
    RestRequest request = new RestRequest() { Method = Method.POST };

    request.AddHeader("Accept", "application/json");
    request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
    request.AddParameter("grant_type", "password");
    request.AddParameter("client_id", _clientId);
    request.AddParameter("client_secret", _clientSecret);
    request.AddParameter("username", _clientUsername);
    request.AddParameter("password", _clientPassword);

    var tResponse = restclient.Execute(request);
    var responseJson = tResponse.Content;
    return JsonConvert.DeserializeObject<Dictionary<string, object>>(
        responseJson)["access_token"].ToString();
}
Run Code Online (Sandbox Code Playgroud)

使用RestSharp进行此操作时我错过了什么?

c# api rest restsharp

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

如何在 vue 组件中动态调整文本大小

我已经构建了一个具有不同小部件的应用程序,您可以将其放入仪表板。每个小部件都包含一个用户希望看到的组件(如果你见过的话,有点像 grafana)。

问题:当用户拖动grid-item增大或减小尺寸时,你如何更新我的组件内部的html以适应新项目的尺寸?

我试过的:

  • 试图将 p 标签包装在 SVG 中并使用视口。
  • 试图将我的尺寸更改为 VW 以通过视口动态缩放,但视口不是组件而是整个 spa。
  • 我尝试使用 this.$parent 获取父大小,并做了一些数学计算来获取文本大小并将其动态分配给一个组件,但这非常混乱。此外,显示的尺寸也不正确。

下面是我使用 vue-grid-layout 包的网格代码

<grid-layout
  ref="widgetGrid"
  :layout.sync="widgets"
  :col-num="12"
  :row-height="verticalSize"
  :is-draggable="editable"
  :is-resizable="editable"
  :is-mirrored="false"
  :responsive="true"
  :autoSize="editable"
  :prevent-collision="false"
  :vertical-compact="false"
  :margin="[10, 10]"
  :use-css-transforms="true"
  @layout-updated="layoutUpdatedEvent"
>
  <grid-item
    :ref="`widget_${widget.i}`"
    v-for="widget in widgets"
    :key="widget.i"
    :x="widget.x"
    :y="widget.y"
    :w="widget.w"
    :h="widget.h"
    :i="widget.i"
    :static="!editable"
  >
    <template>
      <component
        :is="widget.WidgetType"
        :setup="false"
        :widgetConfig="widget.WidgetConfig"
      ></component>
    </template>
  </grid-item>
</grid-layout>
Run Code Online (Sandbox Code Playgroud)

我正在尝试调整文本大小的组件如下。这是一个 vue 文件,我已经包含了样式。

<template>
  <div>
    <div id="clock">
      <p class="date">{{ date }}</p>
      <p class="time">{{ time }}</p>
    </div>
  </div>
</template>

<script>
export default { …
Run Code Online (Sandbox Code Playgroud)

html javascript css vue.js nuxt.js

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

用于与数组进行比较并根据值进行更新的代码永远不会返回更新

我在javascript中有一个代码块,该代码块从API(此数据的真实来源)中获取一系列项目,并且当该数组中每个对象的更新日期都在更新时,应该更新dynamo数据库中的数据不符合我所拥有的 一切对我来说似乎都是正确的,但我总是在回信,即使我已经确认存在更新,也不需要更新任何内容。不太确定我在做什么错。

let count = 0;

    for (let appToCompare of arrayOfFormattedApps) {

        let hasMatch = false;

        for (let index = 1; index < currentCachedListOfApps.length; ++index) {
            var cachedApp = currentCachedListOfApps[index];

            if (cachedApp.ApplicationId === appToCompare.ApplicationId) {
                if (cachedApp.LastUpdateDateTime !== appToCompare.LastUpdateDateTime) {
                    arrayOfAppsWithUpdates.push(appToCompare);
                    hasMatch = true;
                    console.log(cachedApp.AppName + ' is being updated')
                    ++count;
                    break;
                }
            }
        }

        if (hasMatch) {
            arrayOfAppsWithUpdates.push(appToCompare);
        }
    }
Run Code Online (Sandbox Code Playgroud)

javascript node.js

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

标签 统计

javascript ×2

api ×1

c# ×1

css ×1

html ×1

node.js ×1

nuxt.js ×1

rest ×1

restsharp ×1

vue.js ×1