很酷不放纵

文章 评论 浏览 30

很酷不放纵 2025-02-20 17:07:40
.Cities as $c | { mailing_address: (.addresss | map(. * $c)) }

将输出:

{
  "mailing_address": [
    {
      "address_line1": "123 Main Street",
      "address_line2": "Unit 130",
      "city": "New York",
      "zip_code": "10034",
      "state": "NY"
    },
    {
      "address_line1": "5th Avenue",
      "address_line2": "East River Tower",
      "city": "New York",
      "zip_code": "10034",
      "state": "NY"
    }
  ]
}

首先,我们将城市对象保存到变量。
然后,我们创建一个新对象,使用您的 mailing_address 键,循环每个地址,然后添加(*)城市变量

在线尝试

.Cities as $c | { mailing_address: (.addresss | map(. * $c)) }

Will output:

{
  "mailing_address": [
    {
      "address_line1": "123 Main Street",
      "address_line2": "Unit 130",
      "city": "New York",
      "zip_code": "10034",
      "state": "NY"
    },
    {
      "address_line1": "5th Avenue",
      "address_line2": "East River Tower",
      "city": "New York",
      "zip_code": "10034",
      "state": "NY"
    }
  ]
}

First we save the Cities object to a variable.
Then we create a new object, with your mailing_address key, loop over each address and add (*) the Cities variable to it

Try it online

如何使用JQ合并在同一JSON文件中的不同对象和数组

很酷不放纵 2025-02-20 04:23:47

我有点弄清楚了代码,但是由于某种原因,错误弹出了:解析错误:语法错误,意外的令牌“:”

<?php
                    $i = 0;
                    $pages = get_pages([
                      'hierarchical' => 1,
                      'child_of'     => 5,
                      'parent'       => -1,
                      'post_type'    => 'page',
                      'post_status'  => 'publish',
                    ]);?>
                    <div class="direction-carousel">
                    <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
                        
                          <ol class="carousel-indicators">
                          
                          <?php for($i = 0; $i < count($pages); ++$i):
                          
                          ?>
                          <li data-target="#carouselExampleIndicators" data-slide-to="<?= $i;?>"<?=($i==0 ? ' class="active"' : '');?>></li>
                          <?php endfor; 
                          
                          $i = 0;
                          ?>
                        </ol>
                      <div class="carousel-inner">
                        <?php
                          foreach( $pages as $post ):
                            setup_postdata( $post ); ?>
                          <div class="carousel-item<?=($i == 0 : ' active' : '');?>">
                            
                            <?php the_post_thumbnail('direction-carousel', '') ?>
                          </div>
                          <?php
                            ++$i;
                          endforeach;
                          wp_reset_postdata();
                          ?>
                      </div>
                    </div>

I sort of figured out the code, but for some reason an error pops up: Parse error: syntax error, unexpected token ":"

<?php
                    $i = 0;
                    $pages = get_pages([
                      'hierarchical' => 1,
                      'child_of'     => 5,
                      'parent'       => -1,
                      'post_type'    => 'page',
                      'post_status'  => 'publish',
                    ]);?>
                    <div class="direction-carousel">
                    <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
                        
                          <ol class="carousel-indicators">
                          
                          <?php for($i = 0; $i < count($pages); ++$i):
                          
                          ?>
                          <li data-target="#carouselExampleIndicators" data-slide-to="<?= $i;?>"<?=($i==0 ? ' class="active"' : '');?>></li>
                          <?php endfor; 
                          
                          $i = 0;
                          ?>
                        </ol>
                      <div class="carousel-inner">
                        <?php
                          foreach( $pages as $post ):
                            setup_postdata( $post ); ?>
                          <div class="carousel-item<?=($i == 0 : ' active' : '');?>">
                            
                            <?php the_post_thumbnail('direction-carousel', '') ?>
                          </div>
                          <?php
                            ++$i;
                          endforeach;
                          wp_reset_postdata();
                          ?>
                      </div>
                    </div>

在没有插件的WordPress中集成Bootstrap Carousel?

很酷不放纵 2025-02-19 23:58:26

首先,您没有发布部署,因此可以清楚地表明部署。yaml应该参考此配置映射

envFrom: 
  - configMapRef: 
      name: fileprocessing-acracbsscan-configmap

,我不确定,但尝试将数据放在报价上。

"SCHEDULE_RUNNING_TIME": "20"

使用 kubectl描述po&lt; pod_name&gt; -n&lt;命名空间&gt; 为了更清晰地查看故障的状态。

还可以尝试 kubectl获取事件-N&lt; namesp&gt; 以获取当前名称空间的所有事件,也许也会清除原因。

First of all, You did not publish the deployment, So to be clear, the Deployment.yaml should reference this config map

envFrom: 
  - configMapRef: 
      name: fileprocessing-acracbsscan-configmap

Also, I'm not sure but try to put the data on quotes.

"SCHEDULE_RUNNING_TIME": "20"

Use kubectl describe po <pod_name> -n <namespace> in order to get a clearer view on what's the status of the failure.

Try also kubectl get events -n <namespace> To get all events of current namespace, maybe it will clear the reason also.

kubernetes configmap错误验证数据:未知

很酷不放纵 2025-02-19 23:35:57

一种垂直集中元素的现代方法是使用 flexbox

您需要父母来决定身高和一个孩子以中心。

下面的示例将以浏览器内的中心为中心。重要的是(在我的示例中)是设置高度:100% to body html html ,然后 min-heivy:100% 到您的容器。

body, html {
  background: #F5F5F5;
  box-sizing: border-box;
  height: 100%;
  margin: 0;
}

#center_container {
  align-items: center;
  display: flex;
  min-height: 100%;
}

#center {
  background: white;
  margin: 0 auto;
  padding: 10px;
  text-align: center;
  width: 200px;
}
<div id='center_container'>
  <div id='center'>I am center.</div>
</div>

A modern way to center an element vertically would be to use flexbox.

You need a parent to decide the height and a child to center.

The example below will center a div to the center within your browser. What's important (in my example) is to set height: 100% to body and html and then min-height: 100% to your container.

body, html {
  background: #F5F5F5;
  box-sizing: border-box;
  height: 100%;
  margin: 0;
}

#center_container {
  align-items: center;
  display: flex;
  min-height: 100%;
}

#center {
  background: white;
  margin: 0 auto;
  padding: 10px;
  text-align: center;
  width: 200px;
}
<div id='center_container'>
  <div id='center'>I am center.</div>
</div>

如何使用CSS垂直将DIV元素集成为DIV元素?

很酷不放纵 2025-02-19 16:56:31

当您使用 Window Chrome 类将自己的内容扩展到窗口的非客户端区域时,您应该定义自定义字幕按钮您自己:

<Style x:Key="StandardStyle" TargetType="{x:Type Window}">
    <Setter Property="WindowChrome.WindowChrome">
        <Setter.Value>
            <WindowChrome UseAeroCaptionButtons="False" />
        </Setter.Value>
    </Setter>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type Window}">
                <Grid Background="Yellow">
                    <Border  
                            Margin="50"
                           >
                        <ContentPresenter Content="{TemplateBinding Content}"/>
                    </Border>
                    <TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Title}"   
                               VerticalAlignment="Top" HorizontalAlignment="Left"   
                               Margin="36,8,0,0" Foreground="Red"/>
                    <Image Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Icon}"  
                           VerticalAlignment="Top" HorizontalAlignment="Left"  
                           Margin="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(WindowChrome.WindowChrome).ResizeBorderThickness}"   
                           Width="100"  
                           WindowChrome.IsHitTestVisibleInChrome="True"/>
                    <Button Content=""
                                WindowChrome.IsHitTestVisibleInChrome="True"
                                    HorizontalAlignment="Right" VerticalAlignment="Top"
                                    Command="{x:Static ApplicationCommands.Close}">
                        <Button.Style>
                            <Style TargetType="Button">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="Button">
                                            <Grid x:Name="LayoutRoot" Background="Transparent" Width="44" Height="30">
                                                <TextBlock x:Name="txt" Text="{TemplateBinding Content}" FontFamily="Segoe MDL2 Assets" FontSize="10" 
                                                                   Foreground="#999999" HorizontalAlignment="Center" VerticalAlignment="Center"
                                                                   RenderOptions.ClearTypeHint="Auto" TextOptions.TextRenderingMode="Aliased"  TextOptions.TextFormattingMode="Display"/>
                                            </Grid>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver" Value="True">
                                                    <Setter TargetName="LayoutRoot" Property="Background" Value="#E5E5E5"/>
                                                    <Setter TargetName="txt" Property="Foreground" Value="#000000"/>
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </Button.Style>
                    </Button>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

您还需要实现命令/事件处理程序: https://stackoverflow.com/a/61784021/7252182

When you extend your own content into the non-client area of a window using the WindowChrome class, you should define custom captions button yourself:

<Style x:Key="StandardStyle" TargetType="{x:Type Window}">
    <Setter Property="WindowChrome.WindowChrome">
        <Setter.Value>
            <WindowChrome UseAeroCaptionButtons="False" />
        </Setter.Value>
    </Setter>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type Window}">
                <Grid Background="Yellow">
                    <Border  
                            Margin="50"
                           >
                        <ContentPresenter Content="{TemplateBinding Content}"/>
                    </Border>
                    <TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Title}"   
                               VerticalAlignment="Top" HorizontalAlignment="Left"   
                               Margin="36,8,0,0" Foreground="Red"/>
                    <Image Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Icon}"  
                           VerticalAlignment="Top" HorizontalAlignment="Left"  
                           Margin="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(WindowChrome.WindowChrome).ResizeBorderThickness}"   
                           Width="100"  
                           WindowChrome.IsHitTestVisibleInChrome="True"/>
                    <Button Content=""
                                WindowChrome.IsHitTestVisibleInChrome="True"
                                    HorizontalAlignment="Right" VerticalAlignment="Top"
                                    Command="{x:Static ApplicationCommands.Close}">
                        <Button.Style>
                            <Style TargetType="Button">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="Button">
                                            <Grid x:Name="LayoutRoot" Background="Transparent" Width="44" Height="30">
                                                <TextBlock x:Name="txt" Text="{TemplateBinding Content}" FontFamily="Segoe MDL2 Assets" FontSize="10" 
                                                                   Foreground="#999999" HorizontalAlignment="Center" VerticalAlignment="Center"
                                                                   RenderOptions.ClearTypeHint="Auto" TextOptions.TextRenderingMode="Aliased"  TextOptions.TextFormattingMode="Display"/>
                                            </Grid>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver" Value="True">
                                                    <Setter TargetName="LayoutRoot" Property="Background" Value="#E5E5E5"/>
                                                    <Setter TargetName="txt" Property="Foreground" Value="#000000"/>
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </Button.Style>
                    </Button>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

You also need to implement the command/event handler(s): https://stackoverflow.com/a/61784021/7252182

如何更改WPF窗口标题栏背景

很酷不放纵 2025-02-19 16:13:49

实际上,您可以仅使用Windows Direct2D API进行从SVG到ICO或SVG或PNG到ICO的整个转换,而无需任何第三方工具。

我今天构建了该工具。 ICO格式存在一些奇怪的问题,因为它实际上可以通过设置bmpheader.bheight * -1」和PNG 「MSFT博客链接来支持旋转「「直接直接了解旋转。但是许多工具不正确地理解它。因此,最好将直接从SVG或PNG转换为更严格的GUID_WICPIXELFORMAT32BPPBGRA格式,并用于

D2D1_MATRIX_3X2_F transformMatrix = D2D1::Matrix3x2F::Scale(1.0f, -1.0f); // Flip y-axis
transformMatrix._32 = static_cast<float>(renderHeight); // Reposition y-axis origin

查看基础知识以 drawsvgdocument 带有 comptr comptr; DC;

实际上

    // Create PNG encoder
    ComPtr<IWICBitmapEncoder> encoder;
    hr = wicFactory->CreateEncoder(GUID_ContainerFormatPng, nullptr, &encoder);

从中编写ICO格式有点繁重,因为您需要构建正确的 icondir 和一个或多个 icondirentry 每个部分 bitmapinfoheader 您要发射到ICO文件中。总而言之,发现真正在所有工具中使用的正确格式与某些工具都可以使用。我花了大约4个小时的测试和实验。

参见:
https://devblogs.microsoft.s.microsoft.com/oldnewthing/oldnewthing/20101022222-00/? P = 12473

PS,我的动机是能够产生SVG直接在我的PWA和本机应用程序的脚本工具中,然后在部署时间发射PNG和ICO,以在包装中大大节省两个文件尺寸,并仅使用SVG允许相当无限的主题。

You can actually do the entire conversion from SVG to ICO or SVG to PNG or PNG to ICO using ONLY Windows Direct2D APIs without needing any 3rd party tools.

I built that tool today. The ICO format has some wonky issues in that it can actually support rotation 「by setting bmpHeader.biHeight * -1」, and PNG 「MSFT blog link below」 directly but many tools don't understand it properly. So it is best to translate from SVG or PNG directly to a stricter GUID_WICPixelFormat32bppPBGRA format and use

D2D1_MATRIX_3X2_F transformMatrix = D2D1::Matrix3x2F::Scale(1.0f, -1.0f); // Flip y-axis
transformMatrix._32 = static_cast<float>(renderHeight); // Reposition y-axis origin

To see the basics look for DrawSvgDocument with ComPtr<ID2D1DeviceContext5> dc;

and

    // Create PNG encoder
    ComPtr<IWICBitmapEncoder> encoder;
    hr = wicFactory->CreateEncoder(GUID_ContainerFormatPng, nullptr, &encoder);

Actually writing an ICO format from that is a bit more heavy lifting because you need to build the CORRECT ICONDIR and one or more ICONDIRENTRY sections for each BITMAPINFOHEADER entry you want to emit into your ICO file. All in all it is a bit of a one time PITA to discover the correct formats that actually work in all tools vs just some tools. It took me about 4 hours of testing and experimenting.

See also:
https://devblogs.microsoft.com/oldnewthing/20101022-00/?p=12473

p.s., My motivation was to be able to generate SVGs directly in my scripting tool for PWAs and native apps, and then emit PNGs and ICOs at deployment time to save significantly on both file-size in a package and allow fairly infinite theming using only SVGs.

带PNG数据的ICO文件

很酷不放纵 2025-02-19 10:43:14

使用以下方法;

img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)

h,w, c = img.shape

_, thresh = cv2.threshold(img, np.mean(img), 255, cv2.THRESH_BINARY_INV)
edges = cv2.dilate(cv2.Canny(thresh, 0, 255), None)

cnt = sorted(cv2.findContours(edges, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)[-2], key=cv2.contourArea)[-1]
mask = np.zeros((h, w), np.uint8)
masked = cv2.drawContours(mask, [cnt], -1, 255, -1)

dst = cv2.bitwise_and(img, img, mask=masked)
segmented = cv2.cvtColor(dst, cv2.COLOR_BGR2RGB)

Use the following method;

img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)

h,w, c = img.shape

_, thresh = cv2.threshold(img, np.mean(img), 255, cv2.THRESH_BINARY_INV)
edges = cv2.dilate(cv2.Canny(thresh, 0, 255), None)

cnt = sorted(cv2.findContours(edges, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)[-2], key=cv2.contourArea)[-1]
mask = np.zeros((h, w), np.uint8)
masked = cv2.drawContours(mask, [cnt], -1, 255, -1)

dst = cv2.bitwise_and(img, img, mask=masked)
segmented = cv2.cvtColor(dst, cv2.COLOR_BGR2RGB)

如何在图像中分割对象?

很酷不放纵 2025-02-18 08:42:59

您可以以固定的间隔运行计划的任务(每分钟每分钟)然后发送过去/下分钟的所有消息,或者您可以自己使用云任务安排任务(然后是http云功能)自己要么自己(如道格(Doug)所解释的在此文档

此主题之前已经介绍了好几次,所以我建议您还查看:

You can either run a scheduled task at a fixed interval (say every minute) and then send all messages for the past/next minute, or you can use Cloud Tasks to schedule the task (which is then a HTTP Cloud Function) either yourself (as Doug explained here) oras shown in this documentation.

This topic has been covered quite a few times before, so I recommend also checking out:

与Cron Job一起安排Firebase中的推送通知

很酷不放纵 2025-02-18 02:26:55

您可以使用 ctx.resolvedurl 。它将返回您想要的东西,或者您将能够解析所需的部分

You can use ctx.resolvedUrl. It will either return what you want or you'll be able parse the needed part out

next.js如何geterversideprops

很酷不放纵 2025-02-17 06:06:57

msg.author 就足够了,您只需要更改“” backQoute

client.on("message", msg => {
 if (msg.content === ".p1") {
     msg.channel.send('${msg.author}  pong'); // must be `${msg.author}  pong`
 }

如果仅使用 QUOTE> QUOTE 或<代码> double Quote 您仅传递字符串这就是为什么提及不起作用的原因。

msg.author is enough, you just need to change "" to backqoute

client.on("message", msg => {
 if (msg.content === ".p1") {
     msg.channel.send('${msg.author}  pong'); // must be `${msg.author}  pong`
 }

If you only use quote or double quote you only passing a string that's why your mention is not working.

让机器人提及发起命令的人

很酷不放纵 2025-02-17 05:10:58

如果您想在同一主机端口上映射两个服务,我建议使用反向代理,例如 traefik nginx,haproxy,Envoy。强> 此服务的多个容器是在单个主机上创建的,端口将冲突。
反向代理将在当时聆听主机端口80,然后将其转发到端口上的特定Docker容器,该容器未映射到主机上,这取决于诸如Aliases,URL路径之类的一些特征规则。

在yaml config

中,这是什么意思

您可以使用ACI IP本身,这意味着容器组的IP地址类型接受了私人,公共和要打开的端口列表的值。端口空间分隔列表默认值:[80] of az容器

也要制作服务器套接字 lincer() 在某个地址上,您需要明确 bind() 它到接口和端口。将套接字绑定到(接口,端口)对是一个独家过程,重新检查您的许可和服务。

供您参考:

If you want to map two services on same host port, i would suggest to use reverse proxy like Traefik or Nginx, HAProxy, Envoy. Multiple containers for this service are created on a single host, the port will clash.
The reverse proxy will listen the host port 80 at that point it forward to a particular docker container on port which are not mapped to the host depending a few characterized rules like aliases, URL path.

What does it even mean this ipAddress.ports in YAML config

you can use ACI ip itself which means The IP address type of the container group accepted values of Private, Public and list of ports to open. Space-separated list of ports default value: [80] of az container

And also, To make a server socket listen() on a certain address, you need to explicitly bind() it to an interface and port. Binding a socket to an (interface, port) pair was an exclusive process recheck your permission and services.

For your Reference:

https://iximiuz.com/en/posts/multiple-containers-same-port-reverse-proxy/

Azure容器实例:如何公开多个容器的同一端口?

很酷不放纵 2025-02-17 04:22:27

使用这个,它将起作用

public function boot()
{
    $this->registerPolicies();
    
    /** @var CachesRoutes $app */
    $app = $this->app;
    if (!$app->routesAreCached()) {
        Passport::routes();
    }
}

Use this , It will work

public function boot()
{
    $this->registerPolicies();
    
    /** @var CachesRoutes $app */
    $app = $this->app;
    if (!$app->routesAreCached()) {
        Passport::routes();
    }
}

laravel中的routesarecached()方法未定义

很酷不放纵 2025-02-16 22:53:18

thx发表评论,用异步链修复

class RealTimeDatabaseService: RealTimeDatabaseProtocol {
    private let ref = Database.database().reference()
    var driverObserver: UInt?
    var driverReference: DatabaseReference?
    
    func getDriverLocation(_ uuid: String) -> AsyncStream <Result<StoreData, Error>> {
        driverReference = ref.child("driversAvailable").child(uuid)
        
        return AsyncStream { continuation in
            driverObserver = driverReference?.observe(.value) { (snapshot) in
                if let dictionary = snapshot.value as? StoreData {
                    continuation.yield(.success(dictionary))
                } else {
                    continuation.yield(.failure(HTTPError(.badRequest)))
                    continuation.finish()
                }
            }
        }
    }

    func getDriverLocationResult() async  {
        for try await response in 'getDriverLocation'("uid") {
            switch response {
            case .success(let storeDate):
                print("completed: \(storeDate)")
            case .failure(let error):
                print("error: \(error)")
            }
        }
    }

Thx for the comment, fixed it with AsyncStream

class RealTimeDatabaseService: RealTimeDatabaseProtocol {
    private let ref = Database.database().reference()
    var driverObserver: UInt?
    var driverReference: DatabaseReference?
    
    func getDriverLocation(_ uuid: String) -> AsyncStream <Result<StoreData, Error>> {
        driverReference = ref.child("driversAvailable").child(uuid)
        
        return AsyncStream { continuation in
            driverObserver = driverReference?.observe(.value) { (snapshot) in
                if let dictionary = snapshot.value as? StoreData {
                    continuation.yield(.success(dictionary))
                } else {
                    continuation.yield(.failure(HTTPError(.badRequest)))
                    continuation.finish()
                }
            }
        }
    }

    func getDriverLocationResult() async  {
        for try await response in 'getDriverLocation'("uid") {
            switch response {
            case .success(let storeDate):
                print("completed: \(storeDate)")
            case .failure(let error):
                print("error: \(error)")
            }
        }
    }

firebase观察数据异步

很酷不放纵 2025-02-16 10:20:17

在电路中,GPIO0引脚通过10 K电阻连接到VCC。复位引脚上的电压为1.97V。在正常操作中。
我删除了这位重新者,并手动连接了GPIO0销。
正常操作 - &GT; GPIO0未连接
程序模式 - &GT; GPIO0至GND-&GT;打开VCC - &GT; GPIO0至VCC - &GT;未连接(达到正常操作),

我使用了5个ESP8266模块尝试,这些模块在此修改后都正常运行,并且以前没有。

我用眨眼的例子做了
但是,当我在Arduino中加载另一个程序时,它失败了上传到ESP/为什么?
唯一的区别是串行显示器的上传速度。

Arduino文件:
void setup(){
// serial.begin(115200);

当我评论此Lline时,上传到ESP的工作。 (// serial.begin(115200);)
当我删除它时(序列号(115200);)上传到ESP失败。

因此,一旦Arduino草图开始串行,与ESP的通信失败了。

In the circuit the GPIO0 pin is connected to VCC through a 10 k resistor. The voltage on the reset pin is 1.97V. in normal operation.
I removed this resister and connected the GPIO0 pin manually.
Normal operation--> GPIO0 not connected
Program mode --> GPIO0 to GND--> switch on VCC --> GPIO0 to VCC --> not connected (to normal operation)

I tried it with 5 esp8266 modules which all were functioning properly after this modification and did not before.

I did it with the blink example
But when I loaded another program in the arduino, it failed uploading to the esp/ Why?
The only difference was the upload speed of the serial monitor.

the arduino file:
void setup() {
//Serial.begin(115200);

When i commented this lline, the upload to the esp worked. ( //Serial.begin(115200); )
when I uncommented it, ( Serial.begin(115200); ) the upload to the esp failed.

So as soon as the Arduino sketch has a serial begin, the communication to the ESP fails.

我如何解决ESP8266的此错误:“警告:ESPCOMM_SYNC失败错误:ESPCOMM_OPEN失败错误:ESPCOMM_UPLOAD_MEM失败&quot”?

很酷不放纵 2025-02-15 23:35:49

我想发送表单data $('#searchproduct')。
控制器的参数...但是无论我做什么,只有一个参数
被发送!!!

该问题可能与表单元素有关,在绑定表单元素和属性时,我们需要通过页面模型绑定它。您可以参考以下示例代码(使用VS 2022和ASP.NET 6 MVC),然后与您的代码进行比较。

型号:

public class Product
{
    public int Id { get; set; }
    public string Title { get; set; }
    public string UrlImage { get; set; }
    public string Detail { get; set; }
    public decimal Price { get; set; }
}

Home Controller:

    public IActionResult ProductCreate()
    {
        return View();
    }

    [HttpPost]
    [ValidateAntiForgeryToken]
    public IActionResult ProductCreate(Product product)
    {
        return View();
    }

ProductCreate.cshtml:

@model MVCWebApp.Models.Product

@{
    ViewData["Title"] = "ProductCreate";
}

<h1>ProductCreate</h1>

<h4>Product</h4>
<hr />
<div class="row">
    <div class="col-md-4">
        <form id="formprodcreate" asp-action="ProductCreate">
            <div asp-validation-summary="ModelOnly" class="text-danger"></div>
            <div class="form-group">
                <label asp-for="Id" class="control-label"></label>
                <input asp-for="Id" class="form-control" />
                <span asp-validation-for="Id" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="Title" class="control-label"></label>
                <input asp-for="Title" class="form-control" />
                <span asp-validation-for="Title" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="UrlImage" class="control-label"></label>
                <input asp-for="UrlImage" class="form-control" />
                <span asp-validation-for="UrlImage" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="Detail" class="control-label"></label>
                <input asp-for="Detail" class="form-control" />
                <span asp-validation-for="Detail" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="Price" class="control-label"></label>
                <input asp-for="Price" class="form-control" />
                <span asp-validation-for="Price" class="text-danger"></span>
            </div>
            <div class="form-group">
                <input type="submit" value="Create" class="btn btn-primary" /> 
                <input type="button" class="btn btn-primary" id="btnFormSubmit" value="Form Ajax Submit"/> 
                <input type="button" class="btn btn-primary" id="btnSubmit" value="Ajax Submit"/>
            </div>
        </form>
    </div>
</div>

<div>
    <a asp-action="Index">Back to List</a>
</div>

JS代码:[注意] Ajax函数中,无需设置 datatype content> content> contenttype

@section Scripts {
    @{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
    <script type="text/javascript">
        $(function(){
            //use the serialize method to serialize the form.
            $("#btnFormSubmit").click(function(){
                $.ajax({
                    url: "/Home/ProductCreate",
                    type: "Post",
                    beforeSend: function (xhr) {
                        xhr.setRequestHeader("XSRF-TOKEN", $('input:hidden[name="__RequestVerificationToken"]').val());
                    },
                    data: $('#formprodcreate').serialize(), 
                    success: function (result) {
                    }
                 });
            });
            //create a JS object and get the entered value, then transfer the object to the controller.
            $("#btnSubmit").click(function(){
                var product = {};
                product.Id = $("input[name='Id']").val();
                product.Title = $("input[name='Title']").val();
                product.UrlImage = $("input[name='UrlImage']").val();
                product.Detail = $("input[name='Detail']").val();
                product.Price = $("input[name='Price']").val();

                $.ajax({
                    url: "/Home/ProductCreate",
                    type: "Post",
                    beforeSend: function (xhr) {
                        xhr.setRequestHeader("XSRF-TOKEN", $('input:hidden[name="__RequestVerificationToken"]').val());
                    },
                    data: product, 
                    success: function (result) {
                    }
                 });
            });
        });
    </script>
}

输出就是这样:

I want to send the form data $('#SearchProduct').serialize() with a
parameter to the controller... But whatever I do, only one parameter
is sent!!!

The issue might be relating to the form elements, when binding the form element and property, we need to bind it via the page model. You can refer to the following sample code (using VS 2022 and Asp.net 6 MVC) and then compare with your code.

Model:

public class Product
{
    public int Id { get; set; }
    public string Title { get; set; }
    public string UrlImage { get; set; }
    public string Detail { get; set; }
    public decimal Price { get; set; }
}

Home controller:

    public IActionResult ProductCreate()
    {
        return View();
    }

    [HttpPost]
    [ValidateAntiForgeryToken]
    public IActionResult ProductCreate(Product product)
    {
        return View();
    }

ProductCreate.cshtml:

@model MVCWebApp.Models.Product

@{
    ViewData["Title"] = "ProductCreate";
}

<h1>ProductCreate</h1>

<h4>Product</h4>
<hr />
<div class="row">
    <div class="col-md-4">
        <form id="formprodcreate" asp-action="ProductCreate">
            <div asp-validation-summary="ModelOnly" class="text-danger"></div>
            <div class="form-group">
                <label asp-for="Id" class="control-label"></label>
                <input asp-for="Id" class="form-control" />
                <span asp-validation-for="Id" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="Title" class="control-label"></label>
                <input asp-for="Title" class="form-control" />
                <span asp-validation-for="Title" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="UrlImage" class="control-label"></label>
                <input asp-for="UrlImage" class="form-control" />
                <span asp-validation-for="UrlImage" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="Detail" class="control-label"></label>
                <input asp-for="Detail" class="form-control" />
                <span asp-validation-for="Detail" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="Price" class="control-label"></label>
                <input asp-for="Price" class="form-control" />
                <span asp-validation-for="Price" class="text-danger"></span>
            </div>
            <div class="form-group">
                <input type="submit" value="Create" class="btn btn-primary" /> 
                <input type="button" class="btn btn-primary" id="btnFormSubmit" value="Form Ajax Submit"/> 
                <input type="button" class="btn btn-primary" id="btnSubmit" value="Ajax Submit"/>
            </div>
        </form>
    </div>
</div>

<div>
    <a asp-action="Index">Back to List</a>
</div>

Js code: [Note] In the Ajax function, there is no need to set the datatype and contenttype.

@section Scripts {
    @{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
    <script type="text/javascript">
        $(function(){
            //use the serialize method to serialize the form.
            $("#btnFormSubmit").click(function(){
                $.ajax({
                    url: "/Home/ProductCreate",
                    type: "Post",
                    beforeSend: function (xhr) {
                        xhr.setRequestHeader("XSRF-TOKEN", $('input:hidden[name="__RequestVerificationToken"]').val());
                    },
                    data: $('#formprodcreate').serialize(), 
                    success: function (result) {
                    }
                 });
            });
            //create a JS object and get the entered value, then transfer the object to the controller.
            $("#btnSubmit").click(function(){
                var product = {};
                product.Id = $("input[name='Id']").val();
                product.Title = $("input[name='Title']").val();
                product.UrlImage = $("input[name='UrlImage']").val();
                product.Detail = $("input[name='Detail']").val();
                product.Price = $("input[name='Price']").val();

                $.ajax({
                    url: "/Home/ProductCreate",
                    type: "Post",
                    beforeSend: function (xhr) {
                        xhr.setRequestHeader("XSRF-TOKEN", $('input:hidden[name="__RequestVerificationToken"]').val());
                    },
                    data: product, 
                    success: function (result) {
                    }
                 });
            });
        });
    </script>
}

The output is like this:
enter image description here

ASP.NET Core:使用AJAX将对象和参数发送到MVC控制器?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文