小编val*_*eru的帖子

Reactjs 对象列表分组并映射

我正在使用地图在我的应用程序中呈现 op 产品列表。像这样:

<div className={`content ${isLoading ? 'is-loading' : ''}`}>
  <div className="panel">
    {!isLoading && orders.length > 0
      ? orders.map((order, index) => {
          const { productname, image, quantity, orderid, category } = order;
          return (
            <div className="product" key={orderid}>
              <div className="plaatjediv" onClick={this.toggleModal.bind(this)}>
                <img
                  className="img-responsive"
                  data-itemIndex={index}
                  src={image}
                />
              </div>
              <div className="productInfo">
                <p>{productname}</p>
                <p>Aantal: {quantity}</p>
              </div>
              <div className="bdone">
                <button
                  className="btn btn-lg btn-default btndone"
                  data-itemIndex={index}
                  onClick={this.handleDoneAction}
                >
                  Done
                </button>
              </div>
            </div>
          );
        })
      : null}
  </div>
</div>;
Run Code Online (Sandbox Code Playgroud)

状态命令加载了这段代码:

fetch('http://localhost:54408/api/orders/all/testing-9!8-7!6/' + todayy)
  .then(response => response.json())
  .then(parsedJSON …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs

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

ReadAsStringAsync返回虚线描述

我有一个方法ReadJsonUrl获取一个url(字符串地址(例如:https ://www.ah.nl/service/rest/delegate?url=%2Fproducten%2Fproduct%2Fwi224732%2Fsmiths-nibb-it-happy- ones-kruis-rond-paprika))到JSON文件.

此方法读取JSON并在控制台中输出一些数据.

但问题是产品的描述输出如

Smiths Nibb-it hap-py on-es kruis-rond pa-pri-ka

但如果我在我的浏览器中检查JSON它会显示

史密斯Nibb-它快乐的kruis-rond辣椒粉

这就是我想要它打印的方式.

我认为问题是,请求是使用0px x 0xx分辨率浏览器完成的,因此它会返回分开的单词以使其可读.如果我使我的浏览器非常小,那么它也会用破折号显示描述.我在我的代码中添加了一个用户代理,但是没有用.

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

我的代码:

    public static async Task<object> ReadJsonUrl(string address)
    {
        using (HttpClient client = new HttpClient())
        {
            client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36");

            HttpResponseMessage response = await client.GetAsync(address);
            var content = await response.Content.ReadAsStringAsync();
            //JObject obj = JObject.Parse(content);


            var data = Empty.FromJson(content);

            var product = data.Embedded.Lanes[4].Embedded.Items[0].Embedded.Product;

            Console.WriteLine(product.Id);
            Console.WriteLine(product.Description);
            Console.WriteLine(product.PriceLabel.Now);
            Console.WriteLine(product.Availability.Label);
            Console.WriteLine("-------------------------------------");

            System.Threading.Thread.Sleep(5000);

            //the return value is …
Run Code Online (Sandbox Code Playgroud)

c# json dotnet-httpclient

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

更新c#中的列表

我有一个存储库类,其中包含一个列表,其中包含在我的网站上填写表单的人,如果他们将参加我的聚会.我使用GetAllRespones读取值,并使用AddResponse(通过接口)向列表中添加值

现在我想检查某人是否已填写我的表单,如果是,我想检查WillAttend的值是否已更改并更新它.

我可以在这下面看到我做了什么

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using PartyInvites.Abstract;

namespace PartyInvites.Models
{
public class GuestResponseRepository : IRepository

{
    private static List<GuestResponse> responses = new List<GuestResponse>();

    IEnumerable<GuestResponse> IRepository.GetAllResponses()
    {
        return responses;
    }

    bool IRepository.AddResponse(GuestResponse response)
    {
       bool exists = responses.Any(x => x.Email == response.Email);
        bool existsWillAttend = responses.Any(x => x.WillAttend == response.WillAttend);

        if (exists == true)
        {
            if (existsWillAttend == true)
            {
                return false;
            }

           var attend =  responses.Any(x => x.Email == response.Email && x.WillAttend == response.WillAttend); …
Run Code Online (Sandbox Code Playgroud)

c# linq list

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

标签 统计

c# ×2

dotnet-httpclient ×1

javascript ×1

json ×1

linq ×1

list ×1

reactjs ×1