false-language 相关问题


XSL/XSLT - 动态获取父节点及其值

有人可以帮助我吗?我有一个 xml,可以在其中获取节点中节点的名称,例如值、宽度、高度、重量…… 例子: 有人可以帮助我吗?我有一个 xml,可以在其中获取节点中节点的名称,例如值、宽度、高度、重量…… 示例: <?xml version="1.0" encoding="utf-8"?> <Data totalExecutionTime="00:00:00.0076034" totalCount="1">   <Features>     <ProductID id="100" language="NLB" caption="Product ID" captionAlternative="Product ID" unit="" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="" viewGroup="" viewGroupOrder="0" topViewGroupId="b65b432a-1bf1-4fd4-ae92-03418d3204be" topViewGroup="Algemeen" topViewGroupOrder="1" viewOrder="0" form="Complex" dataType="String" readOnly="False" />     <Length id="245" language="NLB" caption="Lengte" captionAlternative="Lengte" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="28813941-54b4-4511-b91e-d9ae53aa03e9" viewGroup="Afmetingen en gewicht" viewGroupOrder="91" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="1" form="Simple" dataType="Number" readOnly="False" />     <Width id="242" language="NLB" caption="Breedte" captionAlternative="Breedte" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="28813941-54b4-4511-b91e-d9ae53aa03e9" viewGroup="Afmetingen en gewicht" viewGroupOrder="91" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="2" form="Simple" dataType="Number" readOnly="False" />     <Height id="244" language="NLB" caption="Hoogte" captionAlternative="Hoogte" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="28813941-54b4-4511-b91e-d9ae53aa03e9" viewGroup="Afmetingen en gewicht" viewGroupOrder="91" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="3" form="Simple" dataType="Number" readOnly="False" />     <Depth id="771" language="NLB" caption="Diepte" captionAlternative="Diepte" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="28813941-54b4-4511-b91e-d9ae53aa03e9" viewGroup="Afmetingen en gewicht" viewGroupOrder="91" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="4" form="Simple" dataType="Number" readOnly="False" />     <Weight id="243" language="NLB" caption="Gewicht" captionAlternative="Gewicht" unit="kg" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="28813941-54b4-4511-b91e-d9ae53aa03e9" viewGroup="Afmetingen en gewicht" viewGroupOrder="91" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="5" form="Simple" dataType="Number" readOnly="False" />     <LoadCapacity id="457" language="NLB" caption="Draagvermogen" captionAlternative="Draagvermogen" unit="kg" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="c9d7dd7e-8a85-47cc-8542-2695e4615f75" viewGroup="Technische specificaties" viewGroupOrder="15" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="6" form="Simple" dataType="Number" readOnly="False" />     <Volume id="435" language="NLB" caption="Inhoud" captionAlternative="Inhoud" unit="l" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="bfaf678b-8b9d-4cea-aa99-08edd8316dc7" viewGroup="Algemene specificaties" viewGroupOrder="13" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="7" form="Simple" dataType="Number" readOnly="False" />     <TireSize id="705" language="NLB" caption="Banden maat" captionAlternative="Banden maat" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="c9d7dd7e-8a85-47cc-8542-2695e4615f75" viewGroup="Technische specificaties" viewGroupOrder="15" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="8" form="Simple" dataType="String" readOnly="False" />     <LoadingScoop id="706" language="NLB" caption="Laadschep" captionAlternative="Laadschep" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="c9d7dd7e-8a85-47cc-8542-2695e4615f75" viewGroup="Technische specificaties" viewGroupOrder="15" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="9" form="Simple" dataType="String" readOnly="False" />   </Features>   <ProductID id="25137" parentId="0" brand="Normal" order="0" createdDate="2020-03-24T15:30:07.21" modifiedDate="2023-11-20T20:01:33.87">     <Value seq="0" modifiedDate="2020-03-24T15:30:10.493">111TA5851</Value>     <Width seq="0" modifiedDate="2020-03-24T15:30:10.493">515</Width>     <Height seq="0" modifiedDate="2020-03-24T15:30:10.493">1100</Height>     <Weight seq="0" modifiedDate="2020-04-02T13:18:09.44">7.7</Weight>     <LoadCapacity seq="0" modifiedDate="2020-03-24T15:30:10.493">150</LoadCapacity>     <LoadingScoop seq="0" modifiedDate="2020-03-24T15:30:10.493">350x170</LoadingScoop>   </ProductID> </Data> 我想要的是动态获取对应父节点的值。我可以获得如下节点名称: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <table> <xsl:for-each select="/Data/ProductID/*"> <xsl:variable name="myVariable" select="name(.)"/> <xsl:variable name="HasValue" select="count(/Data/ProductID/*)" /> <tr> <td><xsl:value-of select="name(.)" /></td> <td><xsl:value-of select="local-name()" /></td> <td><xsl:value-of select="name()" /></td> <td><xsl:value-of select="/Data/node($myVariable)/@unit" /></td> </tr> </xsl:for-each> </table> </xsl:template> </xsl:stylesheet> 但我不知道如何获取响应的父节点及其值,例如单位元素。 提前致谢并致以诚挚的问候 我已经尝试过但没用。我会不断收到错误:解析 '' 期间出现意外的标记 '$myVariable'。 我想你想声明一把钥匙 <xsl:key name="element-key" match="Data/Features" use="name()"/> 然后你想使用例如key('element-name', name())/@unit。


动态获取父节点及其值

我有一个xml,我可以在其中获取节点中节点的名称,例如值、宽度、高度、重量... 例子: 我有一个 xml,可以在其中获取节点中节点的名称,例如值、宽度、高度、重量…… 示例: <?xml version="1.0" encoding="utf-8"?> <Data totalExecutionTime="00:00:00.0076034" totalCount="1">   <Features>     <ProductID id="100" language="NLB" caption="Product ID" captionAlternative="Product ID" unit="" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="" viewGroup="" viewGroupOrder="0" topViewGroupId="b65b432a-1bf1-4fd4-ae92-03418d3204be" topViewGroup="Algemeen" topViewGroupOrder="1" viewOrder="0" form="Complex" dataType="String" readOnly="False" />     <Length id="245" language="NLB" caption="Lengte" captionAlternative="Lengte" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="28813941-54b4-4511-b91e-d9ae53aa03e9" viewGroup="Afmetingen en gewicht" viewGroupOrder="91" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="1" form="Simple" dataType="Number" readOnly="False" />     <Width id="242" language="NLB" caption="Breedte" captionAlternative="Breedte" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="28813941-54b4-4511-b91e-d9ae53aa03e9" viewGroup="Afmetingen en gewicht" viewGroupOrder="91" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="2" form="Simple" dataType="Number" readOnly="False" />     <Height id="244" language="NLB" caption="Hoogte" captionAlternative="Hoogte" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="28813941-54b4-4511-b91e-d9ae53aa03e9" viewGroup="Afmetingen en gewicht" viewGroupOrder="91" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="3" form="Simple" dataType="Number" readOnly="False" />     <Depth id="771" language="NLB" caption="Diepte" captionAlternative="Diepte" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="28813941-54b4-4511-b91e-d9ae53aa03e9" viewGroup="Afmetingen en gewicht" viewGroupOrder="91" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="4" form="Simple" dataType="Number" readOnly="False" />     <Weight id="243" language="NLB" caption="Gewicht" captionAlternative="Gewicht" unit="kg" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="28813941-54b4-4511-b91e-d9ae53aa03e9" viewGroup="Afmetingen en gewicht" viewGroupOrder="91" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="5" form="Simple" dataType="Number" readOnly="False" />     <LoadCapacity id="457" language="NLB" caption="Draagvermogen" captionAlternative="Draagvermogen" unit="kg" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="c9d7dd7e-8a85-47cc-8542-2695e4615f75" viewGroup="Technische specificaties" viewGroupOrder="15" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="6" form="Simple" dataType="Number" readOnly="False" />     <Volume id="435" language="NLB" caption="Inhoud" captionAlternative="Inhoud" unit="l" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="bfaf678b-8b9d-4cea-aa99-08edd8316dc7" viewGroup="Algemene specificaties" viewGroupOrder="13" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="7" form="Simple" dataType="Number" readOnly="False" />     <TireSize id="705" language="NLB" caption="Banden maat" captionAlternative="Banden maat" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="c9d7dd7e-8a85-47cc-8542-2695e4615f75" viewGroup="Technische specificaties" viewGroupOrder="15" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="8" form="Simple" dataType="String" readOnly="False" />     <LoadingScoop id="706" language="NLB" caption="Laadschep" captionAlternative="Laadschep" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="c9d7dd7e-8a85-47cc-8542-2695e4615f75" viewGroup="Technische specificaties" viewGroupOrder="15" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="9" form="Simple" dataType="String" readOnly="False" />   </Features>   <ProductID id="25137" parentId="0" brand="Normal" order="0" createdDate="2020-03-24T15:30:07.21" modifiedDate="2023-11-20T20:01:33.87">     <Value seq="0" modifiedDate="2020-03-24T15:30:10.493">111TA5851</Value>     <Width seq="0" modifiedDate="2020-03-24T15:30:10.493">515</Width>     <Height seq="0" modifiedDate="2020-03-24T15:30:10.493">1100</Height>     <Weight seq="0" modifiedDate="2020-04-02T13:18:09.44">7.7</Weight>     <LoadCapacity seq="0" modifiedDate="2020-03-24T15:30:10.493">150</LoadCapacity>     <LoadingScoop seq="0" modifiedDate="2020-03-24T15:30:10.493">350x170</LoadingScoop>   </ProductID> </Data> 我想要的是动态获取对应父节点的hte值。我可以获得如下节点名称: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <table> <xsl:for-each select="/Data/ProductID/*"> <xsl:variable name="myVariable" select="name(.)"/> <xsl:variable name="HasValue" select="count(/Data/ProductID/*)" /> <tr> <td><xsl:value-of select="name(.)" /></td> <td><xsl:value-of select="local-name()" /></td> <td><xsl:value-of select="name()" /></td> <td><xsl:value-of select="/Data/node($myVariable)/@unit" /></td> </tr> </xsl:for-each> </table> </xsl:template> </xsl:stylesheet> 但是我不知道如何获取相应的父节点及其值,例如单位元素。 我已经尝试过<xsl:value-of select="/Data/$myVariable/@unit" /></td>,但不起作用。我会不断收到错误:Unexpected token '$myVariable' during parsing of '<AnyKindTest>'。 我想你想声明一把钥匙 <xsl:key name="element-key" match="Data/Features" use="name()"/> 然后你想使用例如key('element-key', name())/@unit。 你写道: <xsl:value-of select="/Data/$myVariable/@unit" /> 我认为你的问题可能是重复的 使用 2 个参数进行 xslt 测试 您正在尝试使用 $myVariable,就好像它所保存的字符串可以以文本方式替换到您的 XPath 表达式中一样。您可能想要的是 /Data/*[name()=$myVariable]/@unit 很多人都犯过这个错误,但我不知道为什么。我不认为人们会将变量 $op 设置为“+”或“-”,然后期望 @x $op @y 执行适当的加法或减法。除非他们以前的编程经验完全是用宏语言。


ASP.NET MVC 项目模板在移动设备上无法调整为 100%

我不明白为什么 Web .Net MVC 项目上的默认模板没有在移动设备中调整为 100% 宽度。 我在视图上使用数据表: @模型IEnumerable 我不明白为什么 Web .Net MVC 项目上的默认模板没有在移动设备中调整为 100% 宽度。 我在视图上使用数据表: @model IEnumerable<iziConference.Models.EventAttendee> <h2>Participantes.</h2> <br /> <button><a style="text-decoration: none" href='@Url.Action("Create", new { eventId = ViewBag.EventId })'>Criar Participante</a></button> <button id="at-btn-refresh"> Actualizar</button> <input id="eventId" type="hidden" value="@ViewBag.EventId"> <table id="at-attendees-list" cellpadding="10" border="1" class="row-border stripe"> <thead> <tr> <th>ID</th> <th>Tipo</th> <th>Nome</th> <th>Email</th> <th>Estado </th> </tr> </thead> <tbody> @foreach (var item in Model) { <tr id="[email protected]_Id"> <td style="padding: 5px"> @Html.DisplayFor(modelItem => item.Attendee.Id) </td> <td> @Html.DisplayFor(modelItem => item.AttendeeType) </td> <td> @Html.DisplayFor(modelItem => item.Attendee.Name) </td> <td> @Html.DisplayFor(modelItem => item.Attendee.Email) </td> <td> @if (item.IsActive) { <button id="[email protected]_Id" class="at-btn-active-state active" data-attendee-id="@item.Attendee_Id" data-attendee-name="@item.Attendee.Name" data-active-new-state="false" data-show-confirmation-alert="true">Desactivar</button> } else { <button id="[email protected]_Id" class="at-btn-active-state inactive" data-attendee-id="@item.Attendee_Id" data-attendee-name="@item.Attendee.Name" data-active-new-state="true" data-show-confirmation-alert="true">Activar</button> } </td> </tr> } </tbody> </table> 由脚本加载: var _atteendeesList = "at-attendees-list"; $("#" + _atteendeesList).DataTable({ "paging": false, "info": false, "language": { "search": "Pesquisar:", "info": "Participantes inscritos: _PAGES_" } }); 使用默认的_Layout.cshtml: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>izigo Conference - Gestor de Conteúdos</title> <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" /> <meta name="viewport" content="width=device-width" /> @Styles.Render("~/Content/css") @Scripts.Render("~/bundles/modernizr") </head> <body> <header> <div class="content-wrapper"> <section id="login"> @Html.Partial(MVC.Account.Views._LoginPartial) </section> <div style="padding: 10px;"> @if (Request.IsAuthenticated) { <nav> <ul id="menu"> <li>@Html.ActionLink("Home", MVC.Home.Index())</li> <li>@Html.ActionLink("Participantes", MVC.Attendee.Index())</li> <li>@Html.ActionLink("Check-in", MVC.Checkin.Index())</li> </ul> </nav> } </div> </div> </header> <div id="body"> @RenderSection("featured", required: false) <section class="content-wrapper main-content clear-fix"> @RenderBody() </section> </div> <footer style="padding-left: 25px;"> <div class="content-wrapper"> <div class="float-left"> <p>&copy; @DateTime.Now.Year - <a href="https://www.izigo.pt/conference" target="_blank">izigo Conference</a> - <i>Powered by</i><a href="https://www.izigo.pt" target="_blank">izigo.pt</a></p> </div> </div> </footer> @Scripts.Render("~/bundles/jquery", "~/bundles/iziconference") @RenderSection("scripts", required: false) </body> </html> 研究了 dataTables 库的选项后,我找到了一个创建响应式解决方案的选项: 我已经包含了响应表结构和columnDefs的选项,以选择哪些选项在移动设备中保持可见: $("#" + _atteendeesList).DataTable({ "responsive": true, "columnDefs": [ { responsivePriority: 1, targets: 0 }, { responsivePriority: 2, targets: -1 } ], "paging": false, "info": false, "language": { "search": "Pesquisar:", "info": "Participantes inscritos: _PAGES_" } }); 我还必须在捆绑包中包含数据表扩展的 js 和 css 响应式库(可在此处下载:https://datatables.net/download/): bundles.Add(new ScriptBundle("~/bundles/iziconference").Include( "~/Content/Scripts/datatables.min.js", "~/Content/Scripts/dataTables.responsive.min.js")); // add-on bundles.Add(new StyleBundle("~/Content/css").Include( "~/Content/Styles/datatables.min.css", "~/Content/Styles/responsive.dataTables.min.css"));


理解“?”的使用在 Dart 函数参数中(bool?)

在探索 Dart 的过程中,我在 Dart 语言之旅 (https://dart.dev/guides/language/language-tour#functions) 中遇到了以下代码片段: /// 设置 [bold] 和 [hidden] 标志 ...


如何从 default.master 获取其他内容页面的标题?

我的前文件夹有一个default.Master page和一些其他aspx文件,例如登录。 默认.Master: <%@Master language="C#" CodeBehind="~/default.Master.cs" Inherits="Front.


无法运行flutter项目

我正在尝试让我的 flutter 项目运行。 运行 main.dart 时,我收到此错误消息,我不明白。 Language 语言:Dart 不参与视图提供者 com.jetbr...


将带有 llm-math 的 Agent 添加到 LangChain Expressive Language 实现中

我有这个 LCEL 解决方案: 从 langchain.document_loaders.pdf 导入 PyMuPDFLoader 导入操作系统 从输入导入列表,元组 从 dotenv 导入 load_dotenv 从 langchain.prompts.prompt 导入


防止 json_decode 变成 false 为空值

使用 json_decode 时, false 的布尔值会变成空值。我使用的 json 字符串的值可以为空、false、1 或某个文本值,而我只想使用该字段...


防止 before_create 方法在 false 或 nil 时保存

我有一个 :before_create 方法,它执行一些检查并返回 false 或 true。 def create_subscription_on_gateway 网关 = self.keyword.shortcode.provider create_subscription = 网关。


如何将 com.google.android.material.textfield.TextInputEditText 制作为文本视图?

<com.google.android.material.textfield.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="32dp" android:layout_marginTop="16sp" android:layout_marginEnd="32dp" app:boxStrokeColor="@color/blue"> <com.google.android.material.textfield.TextInputEditText android:layout_width="match_parent" android:layout_height="wrap_content" android:fontFamily="@font/quicksand_bold" android:hint="Full Name" android:textColor="@color/blue" android:textColorHint="@color/blue" /> </com.google.android.material.textfield.TextInputLayout> 我将其用于 Edittext,但我不知道如何将其用于 Textview android:focusable="false" android:clickable="false" android:cursorVisible="false" 将其添加到EditText


svelte:第一次加载时窗口内部宽度未定义

我有这个组件来检查设备大小 从“$lib/stores”导入{deviceSize}; 让内部宽度; $:如果(内部宽度> = 1652){ ...</desc> <question vote="0"> <p>我有这个组件来检查设备尺寸</p> <pre><code>&lt;script lang=&#34;ts&#34;&gt; import { deviceSize } from &#34;$lib/stores&#34;; let innerWidth; $: if (innerWidth &gt;= 1652) { $deviceSize = { xl: true, lg: false, md: false, dsm: false, sm: false, }; } else if (innerWidth &gt;= 1240 &amp;&amp; innerWidth &lt; 1652) { $deviceSize = { xl: false, lg: true, md: false, dsm: false, sm: false, }; } else if (innerWidth &gt;= 794 &amp;&amp; innerWidth &lt; 1240) { $deviceSize = { xl: false, lg: false, md: true, dsm: false, sm: false, }; } else if (innerWidth &gt;= 640 &amp;&amp; innerWidth &lt; 794) { $deviceSize = { xl: false, lg: false, md: false, dsm: true, sm: false, }; } else { $deviceSize = { xl: false, lg: false, md: false, dsm: false, sm: true, }; } $: console.log(innerWidth); &lt;/script&gt; &lt;svelte:window bind:innerWidth /&gt; </code></pre> <p>和像这样的应用程序组件</p> <p><App.svelte></p> <pre><code>&lt;script&gt; const { lg, xl } = $deviceSize; $: isDesktop = xl || lg; &lt;/script&gt; {#if isDesktop} &lt;DesktopComponent/&gt; {/if} {#if !isDesktop} &lt;MobileComponent/&gt; {/if} </code></pre> <p><a href="https://i.stack.imgur.com/6iNXn.png" target="_blank"><img src="https://cdn.txt58.com/i/AWkuc3RhY2suaW1ndXIuY29tLzZpTlhuLnBuZw==" alt="enter image description here"/></a></p> <p>我的问题是innerWidth在初始加载中总是未定义。所以 isDesktop = false,那么即使我使用桌面,也始终渲染 MobileComponent。请帮我解决这个问题。</p> <p>我尝试为 <pre><code>deviceSize</code></pre> 商店设置默认值,但无法按我想要的方式工作,它始终呈现为我使用的任何设备(PC、移动设备)的默认条件。</p> </question> <answer tick="false" vote="0"> <p>根据<a href="https://svelte.dev/docs/svelte-components#:%7E:text=Reactive%20statements%20run%20after%20other%20script%20code%20and%20before%20the%20component%20markup%20is%20rendered%2C" rel="nofollow noreferrer">svelte 文档</a>:</p> <blockquote> <p>反应式语句在其他脚本代码之后、渲染组件标记之前运行</p> </blockquote> <p>意味着 if-else 块在创建 <pre><code>svelte:window</code></pre> 绑定之前运行一次,此时 <pre><code>innerWidth</code></pre> 未定义。</p> <p>为了避免这种情况,您可以将 <pre><code>innerWidth</code></pre> 初始化为正确的值,例如更换</p> <pre><code>let innerWidth; </code></pre> <p>与</p> <pre><code>let innerWidth = window.innerWidth; </code></pre> <p>也就是说,通过使用 <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_media_queries/Using_media_queries" rel="nofollow noreferrer">CSS 媒体查询</a>(而不是 JavaScript)来显示和隐藏标记,您可能会让您的生活变得更轻松。</p> </answer> </body></html>


StrictMode 导致 useState 中断

StrictMode 破坏了 useEffect 内部的 useState。 如果没有 StrictMode 或在构建中,代码可以正常工作。 setIsLoading 应将 useEffect 中的状态设置为 false。 setIsLoading(false) “会修复...


禁用按钮时的角度显示工具提示

<button [disabled]="(!dataConceptSummmaryFlag || dataConceptSummmaryFlag === false) && (!selectedLOBFlag || selectedLOBFlag === false) && (!adsListFlag || adsListFlag === false)" class="lmn-btn lmn-btn-primary" aria-label="Update" (click)="updateSelectedScopes()" [mtTooltip]="disabledContent" > Update </button> <ng-container *ngIf="(!dataConceptSummmaryFlag || dataConceptSummmaryFlag === false) && (!selectedLOBFlag || selectedLOBFlag === false) && (!adsListFlag || adsListFlag === false)"> <ng-template #disabledContent>No New Scopes Values Selected</ng-template> </ng-container> 如果在该条件下禁用按钮,如何在悬停时显示工具提示文本,并且当我将鼠标悬停在其上时,我会看到红色关闭图标。这是我尝试过的,但没有成功 将此添加到覆盖材质样式的文件中: // this workaround allows for the tooltips to appear on disabled buttons (since mouse events aren't fired for them) button:disabled.mat-mdc-tooltip-trigger { pointer-events: auto !important; // remove the ripple effect on hover > span:first-child { display: none; } } 悬停时它将显示没有波纹背景的工具提示。


同时使用 NOT LIKE 和 OR 语句会产生 FALSE 输出

我的下面的 SQL 语句有问题。 NOT LIKE 和 OR 语句生成 FALSE 语句,因为它在不应该生成输出的情况下生成输出,因为我使用的是 NOT LIKE。什...


是否可以有一个闪亮的条件面板,其条件是全局变量?

我的目标是有一个 tabsetPanel 包裹在一个条件面板中,其条件是全局变量为 false。 ui.R 主面板( conditionalPanel("searchPage == \"false\"", 选项卡面板(


为什么 (2,3) 的场景不返回 false 而是返回 true?

一直试图理解为什么当我将 2, 3 传递给这个函数时它返回 true 而不是 false。 函数解决这个(i,j){ 如果(i || j === 1){ 返回真 } 否则如果 (i + j === 1) {


即使标签的可见性设置为 false,也可以查看 Echarts 中突出显示条形的标签

我想在Echarts中将标签的可见性设置为false,可以通过以下方式实现: 标签: { 显示:假 } 不过,我还有另一个设置: 强调: { 焦点:“爵士...


OSClass 中的面包屑导航

我是 OSClass 的新手。 我看见 $breadcrumb = osc_breadcrumb('»', false); 在 header.php 中。 osc_breadcrumb() 在哪里定义?我正在使用现代主题。


Elasticsearch:何时将 omit_norms 选项设置为 false

elasticsearch 中 omit_norms 选项的良好用例是什么?我在 es 网站上找不到足够的解释。


禁用的输入未启用

startbtn.addEventListener("点击", () => { if (startbtnclicked === false) { 时间[0] = 输入小时.值 时间[1] = 输入分钟.值 temp = 输入temp.值 如果(有效(100...


pydantic 可选表单在表单丢失时返回 422

我如何获得可选表格, @app.post("/config", include_in_schema=False) 异步 def postconfig(请求:请求, gitlabtoken:str = 表单(...), gitlaburl:str = 表单(...),


PHP 惰性布尔求值

我有一个条件语句: if($boolean && luckyOperation()){ ...} PHP 是否有惰性布尔求值,即它是否会检查 $boolean,如果它是 false,则不执行...


更改 df.to_latex / PYLATEX 中的“下一页继续”

下午好。我想将短语“下一页继续”从 df.to_latex 更改。 跑步时 将 pylatex 导入到 pl pl.NoEscape(dff1.to_latex(longtable=True, index=False,


比较 2 个不同工作表中的 2 个 A 列,如果它们匹配,请检查第二个工作表中的 B 列,如果为空,则在第一个工作表中返回“FALSE”

我试图让我的“复选框”列(Sheet1 中的 B 列)根据两个条件填写 TRUE 或 FALSE 值 两张表的 A 列之间的匹配 如果“按”列 (


以编程方式设置 windowlightstatusbar 属性

如您所知,我们可以通过以下代码从 xml 设置 windowLightStatusBar。 真实 我需要将此属性 true 更改为 false 或 fal...


Visual Basic for Applications - 检查数字是否为素数不起作用

我有以下 Visual Basic for Applications 代码: 函数 IsPrimeTrialDivision(number As Long) As Boolean 暗淡我只要 如果是数字<= 1 Then IsPrime = False Exit


我想在不可组合的后台线程中调用可组合组件

会话管理器: 类 SessionManager @Inject 构造函数(@ApplicationContext private val context: Context) : 会话服务{ val openAlert = mutableStateOf(false) val Context.dataStore:


std::remove 是否保留删除的元素,或者它们是否可以被覆盖?

int main() { std::vector v(10, false); v[0] = 真; v[1] = 真; auto end_it = 删除(v.begin(), v.end(), true); 对于 (int i = 0; i < v.size(); ++i) cout << ...


Mongoose:如何访问模式方法中的 select:false 属性?

快速代码: var userSchema = new mongoose.Schema({ 用户名:字符串, 密码:{类型:字符串,选择:false} }); userSchema.methods.checkPassword = 函数(密码,完成){ 控制台....


EasyOCR 未向提取的文本添加正确的换行符

以下是代码的要点: 进口菲茨 导入easyocr 从 PIL 导入图像 def extract_text_from_pdf(pdf_path): reader = easyocr.Reader(['en'], download_enabled=False) 提取文本 = ...


在 Jinja 中选择 for 循环内的元素

我正在尝试并排渲染两个不同的表,它们在 Flask 中作为数据帧一起传递 return render_template('rankings.html',tables=[df1.to_html(index=False,classes='data...


Angular 项目不适用于@babylonjs/viewer

我在全球安装了@Angular/[email protected]。我使用命令行“ng new BabylonTest --routing false --style css --skip-git --skip-tests”创建了一个 Angular 项目。 CD 到文件夹“Babyl...


为什么这段代码能够判断二维数组中的数字是否重复?

//检查数独解法的有效性 bool validCheck (int sudoku [25][25], int n, int sqrt_n) { //检查行有效性 对于 (int i=0; i //checking validity of sudoku solution bool validityCheck (int sudoku [25][25], int n, int sqrt_n) { //checking rows validity for (int i=0; i<n; ++i) { // i means place in column bool numCounter [25] = { false }; for (int j=0; j<n; j++){ //j means place in row if (numCounter[(sudoku[i][j])-1] == true){ return false; } else { numCounter[(sudoku[i][j]) -1] = true; } } } //checking columns validity for (int j=0; j<n; ++j) { bool numCounter [25] = {false}; for (int i = 0; i<n; ++i){ if (numCounter[sudoku[i][j]-1] == true){ return false; } else { numCounter[sudoku[i][j]-1]=true; } } } //checking square validity for (int s = 0; s < sqrt_n; s++) { //s means square in column for (int r = 0; r < sqrt_n; r++) {//r means square in row bool numCounter [25] = {false}; int j = sqrt_n * s; for ( ; j < sqrt_n; ++j) { int i = sqrt_n * r; for ( ; i < sqrt_n; ++i){ if (numCounter[sudoku[i][j]-1] == true){ return false; } else { numCounter[sudoku[i][j]-1]=true; } } } } } return true; } 大家好,这段代码使用 bool 来判断一个数字是否在二维数组的行、列或平方根中重复。 是不是一开始bool被设置为false,如果假设值4被重复,那么首先它变成true,然后再次检查并发现它是true,所以我们知道它已经被重复并返回false? 我想我明白了,只是确定一下。 基本上,它有一个包含从1到26的所有号码的清单,检查该号码是否已被使用,如果没有则写入它。 因此,numCounter 是一个包含 25 个布尔值的数组,因为每行只有 25 个数字(1 到 26)。 数组中的每个布尔值都指示索引处的数字是否已被使用。 所以线条 if (numCounter[(sudoku[i][j])-1] == true){ return false; } else { numCounter[(sudoku[i][j]) -1] = true; } 首先检查该数字是否已被使用,如果有,则返回函数一个 false,表示数独不正确;如果不是,则通过将 bool 值设置为 true 来将其设置为已使用的。 在这种情况下,该行 sudoku[i][j] 返回数组数独中实际行位置 (j) 的实际列 (i) 中的数字。这应该给你一个 1 到 26 之间的数字。然后你输入 -1,因为数组从 0 而不是 1 开始。


PHP文件上传并想从列中获取数据(最小值和最大值)

$限制=1; $fileHandle = fopen($inputFileName, "r"); if ($fileHandle === FALSE) { die('打开时出错'。$inputFileName); } // 设置一个变量来保存我们的当前...


AngularBehaviorSubject 在首次加载时不起作用

我在 profile.service.ts 文件中定义了一个BehaviorSubject,该文件将 false 作为初始值,并且我从 ngOnInit 函数中的 profileDialog.component.ts 组件订阅它并更新


即使使用`rejectUnauthorized: false`,postgresql也不接受自签名证书

这是我的代码: 从 'pg' 导入 pg; const { 池 } = pg; 让connectionString = process.env.DB_CONNECTION_STRING 导出常量池=新池({ 连接字符串: 连接字符串, SSL:{


错误。如果包含切片则返回 false

当我有一个包含嵌套在其中的切片的错误结构时,Error.Is 似乎无法正常工作: 包主 进口 ( “错误” “FMMT” “操作系统” ) ...


跨 Google 表格提取数据

我正在努力研究谷歌表格中的公式,以在下面给出的谷歌文档链接中的 PracticeTracker 表格的 J 列中提取 TRUE/FALSE https://docs.google.com/spreadsheets/d/


WillPopScope 已弃用,不应使用。请改用 PopScope。颤动

我收到此警告。我已阅读文档。但我的代码在某些条件下返回 true 或 false 值。我该如何迁移这个? WillPopScope( onWillPop: () 异步 ...


无法反序列化密钥数据 (RSA)。数据可能格式不正确

我有这个烧瓶端点。但 openssl 引发了一个奇怪的错误。 导入jwt @app.route('/api/secure') def secure_endpoint(): 选项 = {'verify_aud': False, 'require_sub': True} 访问...


如何让 yup 数字接受可为空的值?

我有以下检查: nrOfApples: yup.number().min(0).max(999), 现在,如果我将该字段留空,它就会验证为 false。有什么方法可以让 yup.number() 接受空值...


如何停止maven输出“[警告]配置选项'appendAssemblyId'设置为false。”?

我有一个生成jar的maven项目,但没有附加maven-assemble-plugin的appendAssemblyId。 如何让 Maven 停止发出警告:“配置选项‘appendAssemblyId’已设置...


即使我通过 RESTHeart 5.1.5 执行 POST 来添加文档,为什么 Mongo DB 仍检查 _etag?

使用 RESTHeart 5.1.5,我尝试通过 HTTP POST 将文档添加到集合 myapp 中。 POST http://xyz:9998/logs/myapp?checkETag=false { “差异”:{ “地址”: { &


WPF ToggleButton XAML 样式

我有两个切换按钮,我正在尝试组合它们 - 有点。所以第一个按钮根据 IsChecked 是 true 还是 false 来切换图像,但是这个按钮周围有一个边框......


从回调中创建可观察对象

我有一个身份验证防护,当访问站点并且用户已经登录时,它需要异步响应 true/false。 我正在使用 Firebase 的 onAuthStateChanged (链接到文档),它使用


Blazor 内联渲染怪异

我正在使用 Blazor Bootstrap 并尝试在提交表单后更新页面。该表单只是创建一个数据库条目并返回 true 或 false。该页面正在使用禁用的选项卡...


如何修复此内存错误:无法在 Python 中分配

这是我的代码 out = out.T.groupby(level=0, sort=False).sum().T 它给出了这个错误 MemoryError:无法为形状为 (37281, 47002) 和数据类型为 int64 的数组分配 13.1 GiB...


Hibernate PostInsertEventListener.requiresPostCommitHanding 是做什么的?

在文档中它说: 此侦听器是否需要注册事务挂钩后? 这是否意味着,如果我们返回 false,则侦听器将在事务提交之前运行,并且在我之后...


函数参数解析(如果类型可以变化)

我有一个可以通过布尔 onoff 或字典请求调用的函数。如果 onoff 直接作为参数,它可以是 True、False 或 None。如果它来自请求字典,...


javascript中有XNOR运算符吗

我是js新手,我想知道JS中是否有XNOR运算符。我尝试了 !(a^b) 但它给出了奇怪的结果。例如: var a,b=“aa”; ^b 这段代码返回 true,但是 I XNOR 返回 false。 上...


© www.soinside.com 2019 - 2024. All rights reserved.