寄意

文章 评论 浏览 31

寄意 2025-02-20 22:16:20

对于根据C标准的初学者,没有参数的功能主体应

int main( void )

像所示程序中的函数

int (*x)[12], i;

一样贴发。因此,将指针删除

(*x)[i] = i;

导致不确定的行为。

取而代之的是,您可以写作,例如

#include <stdio.h>

int main( void )
{
    enum { N = 12 };
    int a[N];

    int (*x)[N] = &a;

    for ( size_t i = 0; i < N; i++ )
    {
        (*x)[i] = i;
        printf( "%d\n", (*x)[i] );
    }
}

一样写入该程序会更简单,

#include <stdio.h>

int main( void )
{
    enum { N = 12 };
    int a[N];

    int *x = a;

    for ( size_t i = 0; i < N; i++ )
    {
        x[i] = i;
        printf( "%d\n", x[i] );
    }
}

,如果该程序像在此声明中

int *x = a;

将其隐式转换为指向其类型 int *的第一个元素的指针。

在此声明中,

int (*x)[N] = &a;

初始化表达式&amp; a 已经是类型 int( *)[n] 的指针。

因此,在表达式中,

(*x)[i] = i;

子表达*x 产生数组 a 的lvalue。因此,实际上,上述表达式等同于

a[i] = i;

指针中都关注

int *x = a;

在声明和

int ( *x )[N] = &a;

x 存储数组 a 的记忆范围的起始地址,但不同类型。删除第一个指针,您将获得数组 a 的第一个元素。取消第二个指针,您将获得整个数组本身。

For starters according to the C Standard the function main without parameters shall be decalred like

int main( void )

In the shown program you declared an uninitialized pointer

int (*x)[12], i;

that has an indeterminate value. So dereferencing the pointer

(*x)[i] = i;

results in undefined behavior.

Instead you could write for example

#include <stdio.h>

int main( void )
{
    enum { N = 12 };
    int a[N];

    int (*x)[N] = &a;

    for ( size_t i = 0; i < N; i++ )
    {
        (*x)[i] = i;
        printf( "%d\n", (*x)[i] );
    }
}

Though the program will look simpler if to write it like

#include <stdio.h>

int main( void )
{
    enum { N = 12 };
    int a[N];

    int *x = a;

    for ( size_t i = 0; i < N; i++ )
    {
        x[i] = i;
        printf( "%d\n", x[i] );
    }
}

In this declaration

int *x = a;

is implicitly converted to a pointer to its first element of the type int *.

In this declaration

int (*x)[N] = &a;

the initializing expression &a is already a pointer of the type int ( * )[N].

So in the expression

(*x)[i] = i;

the subexpression *x yields lvalue of the array a. So in fact the above expression is equivalent to

a[i] = i;

Pay attention to that in the both declarations

int *x = a;

and

int ( *x )[N] = &a;

the pointers x store the starting address of the memory extent occupied by the array a but have different types. Dereferencing the first pointer you will get the first element of the array a. Dereferencing the second pointer you will get the whole array itself.

我需要帮助理解“指向N Integers”数组的正确用法。初始化

寄意 2025-02-20 17:31:17

一个解决方案是将每个解决方案包装 span input div ,并给出每个 span display:block < /代码>

最好使用类而不是使用内联样式。

 <span>Name </span>
    <Input
      type="text"
      onChange={(e) => setName(e.target.value)}
      value={name}
    />
    <div style={{ flexDirection: "row", display: "flex" }}>
      <div>
      <span
       style={{ display: 'block' }}
      >
        Start Date
      </span>
      <Input
        style={{ flexDirection: "row", width: "45%", flexWrap: "wrap" }}
        type="text"
        onChange={(e) => setStartDate(e.target.value)}
        value={startDate}
      />
      </div>
      <div>
      <span style={{ display: 'block' }}>End Date</span>
      <Input
        style={{ flexDirection: "row", width: "45%", flexWrap: "wrap" }}
        type="text"
        onChange={(e) => setEndDate(e.target.value)}
        value={endDate}
      />
      </div>
    </div>

One solution is wrap each span and input into a div and give each span display: block

It would be better to use classes instead of using inline style.

 <span>Name </span>
    <Input
      type="text"
      onChange={(e) => setName(e.target.value)}
      value={name}
    />
    <div style={{ flexDirection: "row", display: "flex" }}>
      <div>
      <span
       style={{ display: 'block' }}
      >
        Start Date
      </span>
      <Input
        style={{ flexDirection: "row", width: "45%", flexWrap: "wrap" }}
        type="text"
        onChange={(e) => setStartDate(e.target.value)}
        value={startDate}
      />
      </div>
      <div>
      <span style={{ display: 'block' }}>End Date</span>
      <Input
        style={{ flexDirection: "row", width: "45%", flexWrap: "wrap" }}
        type="text"
        onChange={(e) => setEndDate(e.target.value)}
        value={endDate}
      />
      </div>
    </div>

如何使文本跨度在弹性方向行之上

寄意 2025-02-20 14:26:58

尝试一下,这称为辩论,以防万一您需要搜索更多有关它的信息

$(document).ready(function () {
    let oldTimeout = null;
    let timeToWaitBeforeSending = 1000 //ms
    $('#cards-search').on('input', function () {
        if (oldTimeout !== null) {
            clearTimeout(oldTimeout);
        }
        timout = setTimeout(() => {
            cards_page = '';
            cards_search = this.value;
            get_card_data();
        }, timeToWaitBeforeSending );
    });
});

try this, this is called debouncing in case u need to search more about it

$(document).ready(function () {
    let oldTimeout = null;
    let timeToWaitBeforeSending = 1000 //ms
    $('#cards-search').on('input', function () {
        if (oldTimeout !== null) {
            clearTimeout(oldTimeout);
        }
        timout = setTimeout(() => {
            cards_page = '';
            cards_search = this.value;
            get_card_data();
        }, timeToWaitBeforeSending );
    });
});

延迟输入上的JavaScript,因此输入到搜索字段的每个字符确实会发射功能

寄意 2025-02-20 12:22:58

注意:在这里盲目键入,因此代码中可能有一些错别字。

想法是,获取 dataTable 内的行数,然后进行槽,然后做您已经做过的事情。

int NumOfItems = Dt1.AsEnumarable().ToList();

for(int i = 0; i < NumOfItems.Count; i++)
{
   Dt1 = Dt1 .AsEnumerable().GroupBy(r => new { filename = r.Field<string>("filename1"), filesize = r.Field<string>("filesizeinkb") }).Select(g => g.First()).CopyToDataTable();
}

Note: This was blindly typed here, so there might be some typos in the code.

Idea is, get the number of rows inside your DataTable, and go trough each of them, and do what you already did.

int NumOfItems = Dt1.AsEnumarable().ToList();

for(int i = 0; i < NumOfItems.Count; i++)
{
   Dt1 = Dt1 .AsEnumerable().GroupBy(r => new { filename = r.Field<string>("filename1"), filesize = r.Field<string>("filesizeinkb") }).Select(g => g.First()).CopyToDataTable();
}

用LINQ从DataTable中删除重复项,而无需保持重复的条目

寄意 2025-02-20 10:14:23

@Jason

您可以构建APK并手动提交Google吗?

Jasons的建议对我有用,仍然无法使用Visual Studio分发到Google Play,因此手动方法奏效了,根本不值得浪费更多时间试图弄清为什么Visual Studio不像以前那样做。

快速更新:

我恢复了Visual Studio 2022v。17.05

,现在我的iOS建筑/存档作品再次恢复,如果您使用Xamarin,它显然非常不建议您更新视觉工作室。

@Jason

can you build an APK and submit to Google manually?

Jasons suggestion worked for me, still can't use Visual studio to distribute to google play, so the manual approach worked, simply not worth it to waste more time trying to figure out why Visual studio isn't doing as it used to.

Quick update:

I reverted back to Visual Studio 2022 v. 17.05

And now my iOS building/archiving works again, its apparently very ill adviced to update your visual studio if you use Xamarin.

Xamarin Android分布

寄意 2025-02-19 14:14:27

根据您的目标,有很多方法可以解决此问题。

但这是最简单的:

try {
    // ...
} catch(e: any) {
    if (typeof e === "object" && e !== null && e.data) {
        console.log(e.data);
    }
}

请注意,Typescript在 catch 子句中的类型规范方面有局限代码>数据属性或任何东西。

这是a 打字条游乐场。

There are a lot of ways you could fix this, depending what you're going for.

But this is the simplest:

try {
    // ...
} catch(e: any) {
    if (typeof e === "object" && e !== null && e.data) {
        console.log(e.data);
    }
}

Note that TypeScript has limitations surrounding what you can do in terms of type specification in a catch clause, so you can't do something more complicated like declare an error type containing a data property or anything.

Here's the above code in a TypeScript playground.

如何告诉Typescript“尝试catch”语句中的错误是包含特定属性的对象而无需使用“任何类型”?

寄意 2025-02-19 11:45:25

渲染其他所有图标后,渲染“当前位置图标”。

如果是XML,请最后添加。

如果是在Java中,则只需声明并将其添加到最后一个布局。

如果您无法提供代码,则无法提供代码...

编辑:

确定我的想法,我将提供一些代码。

XML:

    <Layout...>
        <Other_Icon.../>
        <Other_Icon.../>
        <Other_Icon.../>
        <Your_Current_Position.../>
    </Layout...>

Java:

    Layout layout=new Layout(...);
    //A lot of other icons...
    layout.addView(icon1);
    layout.addView(icon2);
    layout.addView(icon3);
    //Your position icon...
    layout.addView(your_current_position_icon);

或者,如果您使用的是拖放。

只需最后放置图标即可。

(但是,如果您为确保确定编写编码,那就更好了。)

Render your "current position icon" after you rendered every other icon.

If it's XML then just add it last.

If it's in Java then just declare and add it to the layout last.

Can't provide code if you can't provide code though...

Edit:

Made out my mind, I'll provide some code.

XML:

    <Layout...>
        <Other_Icon.../>
        <Other_Icon.../>
        <Other_Icon.../>
        <Your_Current_Position.../>
    </Layout...>

Or

Java:

    Layout layout=new Layout(...);
    //A lot of other icons...
    layout.addView(icon1);
    layout.addView(icon2);
    layout.addView(icon3);
    //Your position icon...
    layout.addView(your_current_position_icon);

Or, if you are using drag-and-drop.

Just drop the icon last.

(But it would be better if you code it instead just to make sure.)

在Android的另一个图标之上的图标

寄意 2025-02-19 03:38:16

如果其他人正在尝试类似的需求。

chksum.java

import org.springframework.util.StringUtils;
import java.util.zip.CRC32;

public class ChkSum {
    public static long generate(byte[] content){
        CRC32 crc32 = new CRC32();
        crc32.update(content, 0, content.length);
        return crc32.getValue();
    }

    public static int match(String expected, String actual){
        long exp_hash = generate(StringUtils.trimAllWhitespace(expected).getBytes());
        long act_hash = generate(StringUtils.trimAllWhitespace(actual).getBytes());

        return Long.compare(exp_hash,act_hash);
    }
}

功能

  Scenario: Get demo.wsdl
    * def chksum = Java.type('ChkSum')
    Given path '/demo'
    And param wsdl = 'demoLookup.wsdl'
    When method get
    Then status 200
    # note how we focus only on the relevant part of the payload and read expected XML from a file
    #And print 'response: ', response
    * xmlstring exp = read('expected-demo.wsdl')
    * xmlstring act = response
    * def result = chksum.match(exp, act)
    # And match exp == act
    And match result == 0

In case someone else is attempting a similar need.

ChkSum.java

import org.springframework.util.StringUtils;
import java.util.zip.CRC32;

public class ChkSum {
    public static long generate(byte[] content){
        CRC32 crc32 = new CRC32();
        crc32.update(content, 0, content.length);
        return crc32.getValue();
    }

    public static int match(String expected, String actual){
        long exp_hash = generate(StringUtils.trimAllWhitespace(expected).getBytes());
        long act_hash = generate(StringUtils.trimAllWhitespace(actual).getBytes());

        return Long.compare(exp_hash,act_hash);
    }
}

Feature

  Scenario: Get demo.wsdl
    * def chksum = Java.type('ChkSum')
    Given path '/demo'
    And param wsdl = 'demoLookup.wsdl'
    When method get
    Then status 200
    # note how we focus only on the relevant part of the payload and read expected XML from a file
    #And print 'response: ', response
    * xmlstring exp = read('expected-demo.wsdl')
    * xmlstring act = response
    * def result = chksum.match(exp, act)
    # And match exp == act
    And match result == 0

如何创建空手道测试以验证WSDL文件

寄意 2025-02-18 21:11:39

这可能有用。

import pandas as pd

df_json=pd.read_json("input_file.json")
df_json.head()
df_json.to_csv("output_file.csv",index=False)

This could be useful.

import pandas as pd

df_json=pd.read_json("input_file.json")
df_json.head()
df_json.to_csv("output_file.csv",index=False)

converte json文件到CSV文件,并在Excel中使用正确的格式行和列

寄意 2025-02-18 14:19:00

尝试此XPath以找到包含它的文本

(by.xpath,“ // strong [包含(text(),'chấtliệu')]”);
希望它能起作用!

Try this xpath to find the text which contains it

(By.XPATH,"//strong[contains(text(),'Chất liệu')]");
hope it will work!

如何查找文字&#x27;通过使用硒?

寄意 2025-02-17 22:24:54

不要使用位置:绝对; .dropdown-content 。那把它从流中消失了。当它不重叠时,也不需要 z index:1;

/* When the user clicks on the button, toggle between hiding and showing the dropdown content */
function myFunction() {
  document.getElementById("myDropdown").classList.toggle("show");
}

// Close the dropdown menu if the user clicks outside of it
window.onclick = function(event) {
  if (!event.target.matches('.dropbtn')) {
    var dropdowns = document.getElementsByClassName("dropdown-content");
    var i;
    for (i = 0; i < dropdowns.length; i++) {
      var openDropdown = dropdowns[i];
      if (openDropdown.classList.contains('show')) {
        openDropdown.classList.remove('show');
      }
    }
  }
}
.html .body {
  width: 100%;
  height: 100%;
}

body {
  background-color: blanchedalmond;
}

.griddy {
  display: grid;
  grid-template-columns: auto auto auto auto;
  grid-template-rows: 35px;
  background-color: pink;
}

[class^='ssof'] {
  display: grid;
  outline: 1px solid black;
  align-items: center;
  justify-content: center;
}

.topnav a:hover {
  background-color: #ddd;
  color: black;
}

.topnav {
  border: 2px solid;
  background-color: darkcyan;
}


/* .topnav a {
                float: left;
                display: block;
                color: #f2f2f2;
                text-align: center;
                padding: 14px 16px;
                text-decoration: none;
            } */


/* .body {
                background-image: "nico.png";
                display: grid;
                grid-template-rows: auto, 1fr, auto;
                grid-template-columns: 100%;
            } */

.banner {
  display: flex;
  grid-auto-columns: 80% 20%;
  justify-content: center;
  margin-right: auto;
}

.placeme {
  margin-left: auto;
  width: 20%;
  border: 2;
  height: 36px;
  padding: 0 10px;
  outline: 0;
}

.main {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  /*100%*/
  grid-template-rows: auto 1fr auto;
  gap: 20px;
}

.maincontent {
  display: grid;
  /* outline: 3px solid black; */
  grid-template-columns: 2fr 8fr;
  gap: 10px;
  background-color: lightgray;
  outline: solid 8px lightgray;
  /*20% 80%*/
  /* grid-template-rows: auto auto auto auto; */
}


/* [class^='sidenavinline'] { */

.sidenavinline {
  display: inline-grid;
  grid-template-columns: 100%;
  grid-template-rows: 60px 60px 60px;
  /* outline: solid 3px black; */
  grid-auto-rows: 60px;
  gap: 10px;
}


/* .one {
                display: grid;
                outline: solid 2px blue;
    
            } */

[class^='one'] {
  display: grid;
  align-items: center;
  justify-content: center;
  /* outline: 3px dashed #f90; */
  background-color: white;
  font-size: 20px;
  color: #333;
  gap: 10px;
}

.mainmain {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  grid-template-rows: 150px;
  /* outline: solid blueviolet; */
  /* grid-auto-columns: 1fr; */
  grid-auto-rows: 150px;
  gap: 10px;
}

[class^='submain'] {
  /* display: grid; */
  /* outline: dashed 3px black; */
  background-color: white;
  /* grid-auto-rows: 32%; */
  /* position: absolute; */
}

.footy {
  border: 3px solid black;
  padding: 30px;
}


/* Dropdown Button */

.dropbtn {
  background-color: #3498DB;
  color: white;
  padding: 16px;
  font-size: 16px;
  border: none;
  cursor: pointer;
}


/* Dropdown button on hover & focus */

.dropbtn:hover,
.dropbtn:focus {
  background-color: #2980B9;
}


/* The container <div> - needed to position the dropdown content */

.dropdown {
  position: relative;
  display: inline-block;
}


/* Dropdown Content (Hidden by Default) */

.dropdown-content {
  display: none;
  /* position: absolute; */
  background-color: #f1f1f1;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
  /* z-index: 1; */
}


/* Links inside the dropdown */

.dropdown-content a {
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
}


/* Change color of dropdown links on hover */

.dropdown-content a:hover {
  background-color: #ddd
}


/* Show the dropdown menu (use JS to add this class to the .dropdown-content container when the user clicks on the dropdown button) */

.show {
  display: block;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">

</head>


<body>
  <div class="banner"><input type="text" placeholder="Search.." class="placeme"></div>
  <div class="griddy">
    <div class="ssof">home</div>
    <div class="ssof">search</div>
    <div class="ssof">bagicon</div>
    <div class="ssof">account</div>

  </div>

  <div class="topnav">
    <a href="#">Link</a>
    <a href="#">Link</a>
    <a href="#">Link</a>
  </div>

  <div class="main">
    <div class="sidenav"> p </div>


    <div class="maincontent">
      <div class="sidenavinline">
        <div class="one">
          <div class="dropdown">
            <button onclick="myFunction()" class="dropbtn">Dropdown</button>
            <div id="myDropdown" class="dropdown-content">
              <a href="#">Link 1</a>
              <a href="#">Link 2</a>
              <a href="#">Link 3</a>
            </div>
          </div>
        </div>
        <div class="one">b</div>
        <div class="one">c</div>
        <div class="one">b</div>
        <div class="one">e</div>


      </div>
      <div class="mainmain">
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items</div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>

      </div>
    </div>


    <footer>
      <p class="footy">bottom content</p>
    </footer>

  </div>

</body>

Don't use position: absolute; .dropdown-content. That takes it out of the flow. There's also no need for z-index: 1; when it doesn't overlap.

/* When the user clicks on the button, toggle between hiding and showing the dropdown content */
function myFunction() {
  document.getElementById("myDropdown").classList.toggle("show");
}

// Close the dropdown menu if the user clicks outside of it
window.onclick = function(event) {
  if (!event.target.matches('.dropbtn')) {
    var dropdowns = document.getElementsByClassName("dropdown-content");
    var i;
    for (i = 0; i < dropdowns.length; i++) {
      var openDropdown = dropdowns[i];
      if (openDropdown.classList.contains('show')) {
        openDropdown.classList.remove('show');
      }
    }
  }
}
.html .body {
  width: 100%;
  height: 100%;
}

body {
  background-color: blanchedalmond;
}

.griddy {
  display: grid;
  grid-template-columns: auto auto auto auto;
  grid-template-rows: 35px;
  background-color: pink;
}

[class^='ssof'] {
  display: grid;
  outline: 1px solid black;
  align-items: center;
  justify-content: center;
}

.topnav a:hover {
  background-color: #ddd;
  color: black;
}

.topnav {
  border: 2px solid;
  background-color: darkcyan;
}


/* .topnav a {
                float: left;
                display: block;
                color: #f2f2f2;
                text-align: center;
                padding: 14px 16px;
                text-decoration: none;
            } */


/* .body {
                background-image: "nico.png";
                display: grid;
                grid-template-rows: auto, 1fr, auto;
                grid-template-columns: 100%;
            } */

.banner {
  display: flex;
  grid-auto-columns: 80% 20%;
  justify-content: center;
  margin-right: auto;
}

.placeme {
  margin-left: auto;
  width: 20%;
  border: 2;
  height: 36px;
  padding: 0 10px;
  outline: 0;
}

.main {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  /*100%*/
  grid-template-rows: auto 1fr auto;
  gap: 20px;
}

.maincontent {
  display: grid;
  /* outline: 3px solid black; */
  grid-template-columns: 2fr 8fr;
  gap: 10px;
  background-color: lightgray;
  outline: solid 8px lightgray;
  /*20% 80%*/
  /* grid-template-rows: auto auto auto auto; */
}


/* [class^='sidenavinline'] { */

.sidenavinline {
  display: inline-grid;
  grid-template-columns: 100%;
  grid-template-rows: 60px 60px 60px;
  /* outline: solid 3px black; */
  grid-auto-rows: 60px;
  gap: 10px;
}


/* .one {
                display: grid;
                outline: solid 2px blue;
    
            } */

[class^='one'] {
  display: grid;
  align-items: center;
  justify-content: center;
  /* outline: 3px dashed #f90; */
  background-color: white;
  font-size: 20px;
  color: #333;
  gap: 10px;
}

.mainmain {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  grid-template-rows: 150px;
  /* outline: solid blueviolet; */
  /* grid-auto-columns: 1fr; */
  grid-auto-rows: 150px;
  gap: 10px;
}

[class^='submain'] {
  /* display: grid; */
  /* outline: dashed 3px black; */
  background-color: white;
  /* grid-auto-rows: 32%; */
  /* position: absolute; */
}

.footy {
  border: 3px solid black;
  padding: 30px;
}


/* Dropdown Button */

.dropbtn {
  background-color: #3498DB;
  color: white;
  padding: 16px;
  font-size: 16px;
  border: none;
  cursor: pointer;
}


/* Dropdown button on hover & focus */

.dropbtn:hover,
.dropbtn:focus {
  background-color: #2980B9;
}


/* The container <div> - needed to position the dropdown content */

.dropdown {
  position: relative;
  display: inline-block;
}


/* Dropdown Content (Hidden by Default) */

.dropdown-content {
  display: none;
  /* position: absolute; */
  background-color: #f1f1f1;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
  /* z-index: 1; */
}


/* Links inside the dropdown */

.dropdown-content a {
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
}


/* Change color of dropdown links on hover */

.dropdown-content a:hover {
  background-color: #ddd
}


/* Show the dropdown menu (use JS to add this class to the .dropdown-content container when the user clicks on the dropdown button) */

.show {
  display: block;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">

</head>


<body>
  <div class="banner"><input type="text" placeholder="Search.." class="placeme"></div>
  <div class="griddy">
    <div class="ssof">home</div>
    <div class="ssof">search</div>
    <div class="ssof">bagicon</div>
    <div class="ssof">account</div>

  </div>

  <div class="topnav">
    <a href="#">Link</a>
    <a href="#">Link</a>
    <a href="#">Link</a>
  </div>

  <div class="main">
    <div class="sidenav"> p </div>


    <div class="maincontent">
      <div class="sidenavinline">
        <div class="one">
          <div class="dropdown">
            <button onclick="myFunction()" class="dropbtn">Dropdown</button>
            <div id="myDropdown" class="dropdown-content">
              <a href="#">Link 1</a>
              <a href="#">Link 2</a>
              <a href="#">Link 3</a>
            </div>
          </div>
        </div>
        <div class="one">b</div>
        <div class="one">c</div>
        <div class="one">b</div>
        <div class="one">e</div>


      </div>
      <div class="mainmain">
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items</div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>
        <div class="submain"> this is where we put items </div>

      </div>
    </div>


    <footer>
      <p class="footy">bottom content</p>
    </footer>

  </div>

</body>

下拉菜单不是将内容推下,而是在顶部显示?

寄意 2025-02-17 21:45:15

问题在于,您没有在HTMX请求中包含该Alpine.js组件( selectedOrderItem )的一个状态数据。因此,当HTMX交换整个组件时,它将在此过程中丢失 selectordordem 的值。我们需要将此变量发送到后端,并将其包括在模板中。向HTMX请求添加其他数据的最简单方法是在其上使用 X-Model 的隐藏输入元素进行同步数据,然后使用 hx-include 将其添加到请求中。将其放置在组件中的任何位置:

<input type="hidden" name="selected_order_item" x-model="selectedOrderItem">

并修改按钮:

<button 
    class="addButton"
    hx-trigger="click" 
    hx-target="#cart-row" 
    hx-swap="outerHTML"
    hx-include="[name='selected_order_item']" 
    hx-post="{% url 'add_to_cart' idOrder=order.id idProduct=item.product.id  %}?cartAction=1"
>

在后端,我们可以在 request.post 中访问它,例如:

context={
         "order": order,
         "items": items,
         "selectedOrderItem": request.POST.get("selected_order_item", "null")
}

之后在 x-data 中访问了所选的。订单项目将出现。

x-data="{selectedOrderItem: {{selectedOrderItem}} }"

The problem is that you are not including the one state data that this Alpine.js component is having (selectedOrderItem) in the HTMX request. So when HTMX swaps the whole component, it will lose the value of selectedOrderItem during the process. We need to send this variable to the backend and include it in the template. The easiest way to add additional data to the HTMX request is to use a hidden input element with x-model on it to sync data, and then use hx-include to add it to the request. Put this anywhere inside the component:

<input type="hidden" name="selected_order_item" x-model="selectedOrderItem">

And modify the button:

<button 
    class="addButton"
    hx-trigger="click" 
    hx-target="#cart-row" 
    hx-swap="outerHTML"
    hx-include="[name='selected_order_item']" 
    hx-post="{% url 'add_to_cart' idOrder=order.id idProduct=item.product.id  %}?cartAction=1"
>

At the backend now we can access it in request.POST, e.g.:

context={
         "order": order,
         "items": items,
         "selectedOrderItem": request.POST.get("selected_order_item", "null")
}

After that in the x-data the selected order item will appear.

x-data="{selectedOrderItem: {{selectedOrderItem}} }"

如何制作alpinejs“重新渲染” htmx交换后的组件

寄意 2025-02-17 19:36:30

请考虑以下方法

with temp as (
  select *, 0 goal, 0 point from
  (select distinct saison from your_table),
  (select distinct stage from your_table),
  (select distinct team from your_table, unnest([team_home, team_away]) team)
)
select distinct saison, stage, team, 
  sum(goal) over prev_stages team_goals,
  sum(point) over prev_stages team_points
from (
  select * except(col) from your_table 
  unpivot ((team, goal, point) for col in 
    ((team_home, home_goal, home_point), (team_away, away_goal, away_point))
  )
  union all select * from temp
)
window prev_stages as (
  partition by saison, team order by stage 
  range between unbounded preceding and current row
)             

如果应用于问题中的示例数据 - 输出为

Consider below approach

with temp as (
  select *, 0 goal, 0 point from
  (select distinct saison from your_table),
  (select distinct stage from your_table),
  (select distinct team from your_table, unnest([team_home, team_away]) team)
)
select distinct saison, stage, team, 
  sum(goal) over prev_stages team_goals,
  sum(point) over prev_stages team_points
from (
  select * except(col) from your_table 
  unpivot ((team, goal, point) for col in 
    ((team_home, home_goal, home_point), (team_away, away_goal, away_point))
  )
  union all select * from temp
)
window prev_stages as (
  partition by saison, team order by stage 
  range between unbounded preceding and current row
)             

if applied to sample data in your question - output is

enter image description here

如何总和每个值和每个阶段

寄意 2025-02-17 19:29:54

可以按插入顺序检索dict键,但仍然是一个集合,无论顺序如何,设置都应比较。实际上,所有设置比较操作都可以工作(并在适当的情况下返回Python SET )。如果 d1 |,那将很奇怪D2 根据插入顺序进行不同的操作。平等是相同的。

Dict keys may be retrieved in insertion order but its still a set, and sets should compare regardless of order. In fact, all set comparison operations work (and return python set when appropriate). It would be strange if d1 | d2 operated differently depending on insertion order. Equality is the same.

dict.keys()平等,订单无关紧要

寄意 2025-02-17 10:38:13

目前尚不清楚您要如何汇总(总和一个更改值是很有意义的?)。还不清楚如果还有其他类型的更改,您想要什么。

但是您可以使用这样的有条件聚集

SELECT
  OilPrice = SUM(CASE WHEN PriceName = 'OilPrice' THEN PriceVal END), 
  OilPrice_CHANGE = SUM(CASE WHEN PriceName = 'OilPrice' THEN PriceVal_Change END),
  t.Portfolio,
  t.benchmark,
  t.EffectiveDate
FROM #temptable t
GROUP BY
  t.Portfolio,
  t.benchmark,
  t.EffectiveDate;

It's unclear exactly how you want to aggregate (does it make sense to sum a Change value?). Also unclear is what result you want if there are other types of changes.

But you can use conditional aggregation like this

SELECT
  OilPrice = SUM(CASE WHEN PriceName = 'OilPrice' THEN PriceVal END), 
  OilPrice_CHANGE = SUM(CASE WHEN PriceName = 'OilPrice' THEN PriceVal_Change END),
  t.Portfolio,
  t.benchmark,
  t.EffectiveDate
FROM #temptable t
GROUP BY
  t.Portfolio,
  t.benchmark,
  t.EffectiveDate;

db<>fiddle

如何进行多个枢轴

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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