target-platform 相关问题


安装 Google Cloud Platform for Eclipse 时出错:缺少 javax.annotation 依赖项

我在尝试安装适用于 Eclipse 的 Google Cloud Platform 插件时遇到问题。安装过程失败并显示以下错误消息: 无法完成安装,因为...


在 Jenkins 管道中使用“docker buildx build”时出现“未知标志:--platform”

我使用的是RedHat-7系统。我希望通过 Jenkins Pipeline 来实施 DevOps。 但是当我使用 docker buildx 构建功能时,Jenkins 说“未知标志:--platform”。 我运行我的詹金斯......


如何删除所有 Google Cloud Platform (GCP) 资源中的资源级权限

如何删除所有 Google Cloud Platform (GCP) 资源中的资源级权限? 例如,计算虚拟机实例可共享给另一个 GCP 用户,而无需分配 IAM 角色。有没有...


为什么我不能使用数据类的字段作为jetpack compose中lazyColumn的item的key?

一个非常非常简单的例子(implementation(platform("androidx.compose:compose-bom:2023.08.00"))): com.study.myapplication 包 导入 android.os.Bundle 导入 androidx.activity。


使用 VS Code 提供额外的配置文件

我们如何使用 Visual Studio Code 使用 https://github.com/ballerina-platform/ballerina-spec/blob/master/configurable/spec.md# located-toml-files 中指定的多个 .toml 文件? (假设...


更新API Platform 3.0相关实体

我正在尝试通过主实体更新相关实体。例如,我有产品和优惠。我向 /products 发了一个帖子 { "name": "样品产品", “优惠”:...


自定义注释的外推属性值

我编写了一个 spring-boot 测试并创建了一个自定义注释: @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @SpringBootTest @AutoConfigureMockMvc @ActiveProfiles(“集成测试...


如何使用 Docker 在 Ubuntu 上安装 nvm?

到目前为止我有这个: 来自 --platform=linux/amd64 amd64/ubuntu:noble 环境术语 Linux ENV DEBIAN_FRONTEND 非交互式 SHELL [“/bin/bash”,“-c”] 环境外壳 /bin/bash 运行 apt upd...


在 Hyperledger Firefly Fabric 中部署链码时出错

当您运行以下命令来发起智能合约时: ff 部署结构开发测试 asset_transfer.zip firefly asset_transfer 1.0 我收到以下错误: 错误:docker run --platform linux/...


如果类型是从变量进行数据绑定,则通过 <object> 标签在 Angular 中显示 pdf 无法在 Chrome 中工作

我正在尝试通过 标签在 Chrome 中显示 pdf。 如果我手动编写类型,它会起作用: 不工作 但是... 我正在尝试通过 <object> 标签在 Chrome 中显示 pdf。 如果我手动写 type: 就可以了 <object [data]="getUrl(true)" type="application/pdf"> Not working </object> 但如果我从变量读取类型则不会: <object [data]="getUrl(true)" [type]="file.mimeType"> Not working </object> 为什么?这是一些非常奇怪的错误,还是我做错了什么可怕的事情。 这里是plunkr。 它可以在 Firefox 中运行(所有 4 个对象都会显示),但不能在 Chrome 中运行 (Version 74.0.3729.169 (Official Build) (64-bit)): 我遇到了同样的问题,但我不明白原因。 就我而言,我决定在基于 Blink 引擎的浏览器中使用“embed”元素而不是“object”元素。 <ng-template #blinkPlatformViewer> <embed [src]="getUrl(true)" [type]="file.mimeType"/> </ng-template> <object *ngIf="!isBlinkPlatform; else blinkPlatformViewer" [data]="getUrl(true)" [type]="file.mimeType"> Not working </object> import { Platform } from '@angular/cdk/platform'; import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'; export class FileContentComponent { constructor(private readonly sanitizer: DomSanitizer, private readonly platform: Platform) { } get isBlinkPlatform(): boolean { return this.platform.BLINK; } }


如何使用 API Platform 和 Gedmo Translatable 查询可翻译属性

我正在使用 Symfony 6 + API 平台 + Gedmo Translatable。 更新/发布项目工作正常并正确存储翻译。 另外,以正确的语言获得集合是......


MariaDB 10.11 Windows 备份身份验证插件“auth_gssapi_client”无法加载

在 Windows 上安装了 MariaDB 10.11。尝试使用进行备份 $ mariabackup --backup --target-dir=F:/backup --user=root --password= https://mariadb.com/kb/en/full-backup-and-restore-with-mariabackup/


XCode 15 没有这样的模块'__ObjC'

当我运行 pod install 时,这些磨损就会出现。 [!] Runner [Debug] 目标会覆盖 Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig 中定义的 ENABLE_BITCODE 构建设置。这……


无法验证应用程序默认凭据

我正在关注这里的文档,它说: 应用程序向 Google Cloud Platform API 服务进行身份验证的最简单方法是使用应用程序默认凭据 (ADC)。服务使用...


如何在云端托管Python项目(特别是Google Cloud Platform)

我有一个关于在云服务器上托管个人项目的非常简单的(我认为)问题。目前,我每天早上都手动运行我的脚本。我想通过


无法加载DLL“找不到模块HRESULT:0x8007007E”

我有 C# WPF 应用程序,其中使用了 C++ DLL 库。当我构建项目时,它会成功构建,并且所有 DLL 和 exe 都存储在 bin/(Platform) eg(bin/Debug) 文件夹中。 现在如果我...


应用程序无法识别手势,例如在 Angular 11 中使用 Hammer.JS 进行平移

我无法在使用 Hammer.JS 的 Angular 应用程序中识别任何手势,例如滑动、平移。它的设置是这样的: 包.json: “@角度/核心”:“11.0.5”, “@Angular/platform-br...


从 adb shell 获取正在运行的 LineageOS 内核配置

我已经从源代码构建了 LineageOS 18.1 并在 ARM 设备上刷新了它。在构建主机上,我可以看到 lineage/out/target/product/jfltexx/obj/KERNEL_OBJ/.config 包含 KERNEL_IKCONFIG=y


在 Docker 中的 Ubuntu 上安装最新版本 Node (v20) 的说明不起作用?

我只是按照说明在 Ubuntu 上的 docker 中安装了最新版本的 Node (v20),在我的 Dockerfile 中包含以下内容: 来自 --platform=linux/amd64 ubuntu:22.04 运行 apt-get update 运行 apt-get...


带有私有子的 VBA 代码处理时间太长

所以,我有 1903 行代码,这些代码合并在与 Private Sub Worksheet_Change (ByVal target As Range)一起使用的三个函数中。它们都工作得很好,但由于它是 1903 行,所以


如何在 AWS Elastic Beanstalk 环境/应用程序中运行 artisan migrate?

我已经完成了所有这些事情来部署我的应用程序,但我无法在部署中运行 php artisan migrate。我已经尝试了从container_commands到.ebextensions/.platform/hooks的许多解决方案,但没有任何效果......


如何使用 wasm-bindgen 和 --target no-modules 导入 JavaScript 函数?

我正在尝试弄清楚如何使用 Rust 和 wasm-bindgen 调用 JavaScript 函数。由于缺乏浏览器支持,我无法将 wasm-bindgen 与 ES6 模块与 Web Worker 一起使用。 到目前为止...


使用 mysql db 运行 spring boot 应用程序的 docker compose 时退出状态 1

我正在尝试文档化 Spring Boot 的应用程序,该应用程序也使用 mysql 数据库 下面是docker文件 FROM maven:3.8.3-openjdk-17 AS 构建 暴露8081 添加/target/oks-0.0.1-SNAPSHOT.jar...


我想使用“data-target”在特定 URL 添加活动

但是,如果在 URL 中添加其他文本,则 active 将丢失。 即使 URL 中添加了其他文本,如果它包含特定的“数据目标”,我也希望使其保持活动状态。 例如,如果起源...


具有 TimestampableEntity 特征的实体在 PUT 操作中失败

我正在全新安装 API Platform (v3.2.7),并且使用 Gedmo\Timestampable\Traits\TimestampableEntity 这是我的实体(问候语示例) 我正在全新安装 API Platform (v3.2.7),并且正在使用 Gedmo\Timestampable\Traits\TimestampableEntity 这是我的实体(问候语示例) <?php namespace App\Entity; use ApiPlatform\Metadata\ApiResource; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; use Gedmo\Timestampable\Traits\TimestampableEntity; #[ApiResource] #[ORM\Entity] class Greeting { use TimestampableEntity; #[ORM\Id] #[ORM\Column(type: "integer")] #[ORM\GeneratedValue] private ?int $id = null; #[ORM\Column] #[Assert\NotBlank] public string $name = ""; public function getId(): ?int { return $this->id; } } 和我的 config/services.yaml gedmo.listener.timestampable: class: Gedmo\Timestampable\TimestampableListener tags: - { name: doctrine.event_listener, event: 'prePersist' } - { name: doctrine.event_listener, event: 'onFlush' } - { name: doctrine.event_listener, event: 'loadClassMetadata' } 它在 POST 操作上工作正常,但在执行 PUT 时失败。我收到此错误 执行查询时发生异常:SQLSTATE[23000]: 完整性约束违规:1048 列“created_at”不能 空 我使用的版本是:symfony 6.4.1,doctrine 2.12,gedmo 3.14 我最终做的是使用 PATCH 而不是 PUT。所以我可以编辑部分实体,并且特征仍然更新 updated_at 字段


为什么NLog不每天归档

NLog 存档每天都不起作用。但它每分钟都有效 NLog版本5.0.7 这是我的配置 NLog 每天存档不起作用。但它每分钟都有效 NLog版本5.0.7 这是我的配置 <target name="Httpfile" layout="${longdate} ${uppercase:${level}} correlationId-${activityid} - ${message} ${exception:format=tostring}" xsi:type="File" fileName="${logFullName}-http-api-${shortdate}.log" archiveFileName="${logFullNameArchive}-archive-Http-api-${shortdate}-{#####}.zip" archiveEvery="Day" concurrentWrites="true" keepFileOpen="false" archiveNumbering="DateAndSequence" maxArchiveFiles="30" maxArchiveDays="7" enableArchiveFileCompression="true" /> 使用 archiveEvery="Minute" 效果很好 不支持在NLog FileTarget中混合静态和动态归档逻辑。 使用静态归档逻辑时,不应在 ${shortdate} 和 fileName="..." 中使用 archiveFileName="..."。 像enableArchiveFileCompression="true"这样的一些功能仅受静态归档逻辑支持: <target name="Httpfile" layout="${longdate} ${uppercase:${level}} correlationId-${activityid} - ${message} ${exception:format=tostring}" xsi:type="File" fileName="${logFullName}-http-api.log" archiveFileName="${logFullNameArchive}-archive-Http-api-{#####}.zip" archiveNumbering="DateAndSequence" archiveDateFormat="yyyyMMdd" archiveEvery="Day" concurrentWrites="true" keepFileOpen="false" maxArchiveFiles="30" maxArchiveDays="7" enableArchiveFileCompression="true" /> 另请参阅:https://github.com/NLog/NLog/wiki/FileTarget-Archive-Examples


错误 2911:无法删除文件夹 C:\Config.Msi\

我有一个创建桌面快捷方式的安装: 我的安装会创建桌面快捷方式: <Shortcut Id="SC.Desktop" Directory="DesktopFolder" Name="!(bind.Property.ProductName)" WorkingDirectory="INSTALLDIR" Target="[INSTALLDIR]testfile.txt" /> <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="integer" Name="DesktopIcon" Value="1" KeyPath="yes" /> 安装后一切正常,详细日志中没有错误。 在卸载时,我在详细日志中收到错误: DEBUG: Error 2911: Could not remove the folder C:\Config.Msi\. 如何解决这个问题? 这不是真正的错误消息。这只是 Windows 安装程序在自言自语。类似的文件和文件夹通常会在重新启动时清理。


HTML如何使用javascript清除输入?

我有这个输入,每次我们点击它里面的时候它都会被清除。 问题: 我只想在 value = [email protected] 时清除 函数clearThis(tar...</desc> <question vote="47"> <p>我有这个INPUT,每次我们点击它里面它就会清除。</p> <p>问题: 我只想在值 = <a href="/cdn-cgi/l/email-protection" data-cfemail="2d485548405d41426d485548405d4142034e4240">[电子邮件受保护]</a></p> 时清除 <pre><code>&lt;script type=&#34;text/javascript&#34;&gt; function clearThis(target) { target.value= &#34;&#34;; } &lt;/script&gt; &lt;input type=&#34;text&#34; name=&#34;email&#34; value=&#34;<a href="/cdn-cgi/l/email-protection" data-cfemail="9cf9e4f9f1ecf0f3dcf9e4f9f1ecf0f3b2fff3f1">[email protected]</a>&#34; size=&#34;30&#34; onfocus=&#34;clearThis(this)&#34;&gt; </code></pre> <p>有人可以帮我做到这一点吗? 我不知道如何比较,我已经尝试过但没有成功。</p> </question> <answer tick="true" vote="57"> <pre><code>&lt;script type=&#34;text/javascript&#34;&gt; function clearThis(target) { if (target.value == &#39;<a href="/cdn-cgi/l/email-protection" data-cfemail="4a2f322f273a26250a2f322f273a262564292527">[email protected]</a>&#39;) { target.value = &#34;&#34;; } } &lt;/script&gt; </code></pre> <p>这真的是您想要的吗?</p> </answer> <answer tick="false" vote="18"> <p>对我来说这是最好的方法:</p> <p></p><div data-babel="false" data-lang="js" data-hide="false" data-console="false"> <div> <pre><code>&lt;form id=&#34;myForm&#34;&gt; First name: &lt;input type=&#34;text&#34; name=&#34;fname&#34; value=&#34;Demo&#34;&gt;&lt;br&gt; Last name: &lt;input type=&#34;text&#34; name=&#34;lname&#34;&gt;&lt;br&gt;&lt;br&gt; &lt;input type=&#34;button&#34; onclick=&#34;myFunction()&#34; value=&#34;Reset form&#34;&gt; &lt;/form&gt; &lt;script&gt; function myFunction() { document.getElementById(&#34;myForm&#34;).reset(); } &lt;/script&gt;</code></pre> </div> </div> <p></p> </answer> <answer tick="false" vote="4"> <p>您可以使用属性<pre><code>placeholder</code></pre></p> <pre><code>&lt;input type=&#34;text&#34; name=&#34;email&#34; placeholder=&#34;<a href="/cdn-cgi/l/email-protection" data-cfemail="42273a272f322e2d02273a272f322e2d6c212d2f">[email protected]</a>&#34; size=&#34;30&#34; /&gt; </code></pre> <p>或者在旧版浏览器上尝试这个</p> <pre><code>&lt;input type=&#34;text&#34; name=&#34;email&#34; value=&#34;<a href="/cdn-cgi/l/email-protection" data-cfemail="bdd8c5d8d0cdd1d2fdd8c5d8d0cdd1d293ded2d0">[email protected]</a>&#34; size=&#34;30&#34; onblur=&#34;if(this.value==&#39;&#39;){this.value=&#39;<a href="/cdn-cgi/l/email-protection" data-cfemail="aacfd2cfc7dac6c5eacfd2cfc7dac6c584c9c5c7">[email protected]</a>&#39;;}&#34; onfocus=&#34;if(this.value==&#39;<a href="/cdn-cgi/l/email-protection" data-cfemail="03667b666e736f6c43667b666e736f6c2d606c6e">[email protected]</a>&#39;){this.value=&#39;&#39;;}&#34;&gt; </code></pre> </answer> <answer tick="false" vote="4"> <p>您可以使用占位符,因为它可以为您做到这一点,但对于不支持占位符的旧浏览器,请尝试以下操作:</p> <pre><code>&lt;script&gt; function clearThis(target) { if (target.value == &#34;<a href="/cdn-cgi/l/email-protection" data-cfemail="402538252d302c2f002538252d302c2f6e232f2d">[email protected]</a>&#34;) { target.value = &#34;&#34;; } } function replace(target) { if (target.value == &#34;&#34; || target.value == null) { target.value == &#34;<a href="/cdn-cgi/l/email-protection" data-cfemail="73160b161e031f1c33160b161e031f1c5d101c1e">[email protected]</a>&#34;; } } &lt;/script&gt; &lt;input type=&#34;text&#34; name=&#34;email&#34; value=&#34;<a href="/cdn-cgi/l/email-protection" data-cfemail="ddb8a5b8b0adb1b29db8a5b8b0adb1b2f3beb2b0">[email protected]</a>&#34; size=&#34;x&#34; onfocus=&#34;clearThis(this)&#34; onblur=&#34;replace(this)&#34; /&gt; </code></pre> <p>代码说明:当文本框获得焦点时,清除该值。当文本框未聚焦且文本框为空时,替换值。</p> <p>我希望这有效,我一直遇到同样的问题,但后来我尝试了这个,它对我有用。</p> </answer> <answer tick="false" vote="0"> <p>试试这个:</p> <pre><code>&lt;script type=&#34;text/javascript&#34;&gt; function clearThis(target){ if(target.value == &#34;<a href="/cdn-cgi/l/email-protection" data-cfemail="67021f020a170b0827021f020a170b084904080a">[email protected]</a>&#34;) { target.value= &#34;&#34;; } } &lt;/script&gt; </code></pre> <p></p> </answer> <answer tick="false" vote="0"> <pre><code>&lt;script type=&#34;text/javascript&#34;&gt; function clearThis(target){ if (target.value === &#34;<a href="/cdn-cgi/l/email-protection" data-cfemail="a2c7dac7cfd2cecde2c7dac7cfd2cecd8cc1cdcf">[email protected]</a>&#34;) { target.value= &#34;&#34;; } } &lt;/script&gt; &lt;input type=&#34;text&#34; name=&#34;email&#34; value=&#34;<a href="/cdn-cgi/l/email-protection" data-cfemail="c7a2bfa2aab7aba887a2bfa2aab7aba8e9a4a8aa">[email protected]</a>&#34; size=&#34;30&#34; onfocus=&#34;clearThis(this)&#34;&gt; </code></pre> <p>在这里尝试一下:<a href="http://jsfiddle.net/2K3Vp/" rel="nofollow">http://jsfiddle.net/2K3Vp/</a></p> </answer> <answer tick="false" vote="0"> <p>你不需要为此烦恼。就写吧</p> <pre><code>&lt;input type=&#34;text&#34; name=&#34;email&#34; placeholder=&#34;<a href="/cdn-cgi/l/email-protection" data-cfemail="06637e636b766a6946637e636b766a692865696b">[email protected]</a>&#34; size=&#34;30&#34;&gt; </code></pre> <p>用占位符替换该值</p> </answer> <answer tick="false" vote="0"> <p>不要使用 <strong>placeholder</strong> 属性清除名称文本,这是一个很好的做法</p> <pre><code>&lt;input type=&#34;text&#34; placeholder=&#34;name&#34; name=&#34;name&#34;&gt; </code></pre> </answer> <answer tick="false" vote="0"> <p>我对所有这些答案感到惊讶,没有人提到最简单、现代的方法来做到这一点:</p> <pre><code>&lt;input type=&#34;text&#34; placeholder=&#34;Your Name&#34; onfocus=&#34;this.placeholder=&#39;&#39;&#34; onblur=&#34;this.placeholder=&#39;Your Name&#39;&#34; &gt; </code></pre> <p>仅当您想在用户单击远离输入后恢复原始占位符时,才需要 <pre><code>onblur</code></pre>。</p> </answer> </body></html>


NG8001:“app-welcome”不是已知元素:

我的 Angular 应用程序遇到问题,收到错误 8001。我不知道如何处理它。谁能帮我这个?谢谢你! 应用程序组件.html {{标题}}&l... 我的 Angular 应用程序遇到问题,收到错误 8001。我不知道如何处理它。谁能帮我这个?谢谢! app.component.html <h1>{{ title }}</h1> <p>Congratulations! Your app is running. 🎉</p> <app-welcome></app-welcome> app.component.ts import { Component } from '@angular/core'; import { CommonModule } from '@angular/common'; import { RouterOutlet } from '@angular/router'; @Component({ selector: 'app-root', standalone: true, imports: [CommonModule, RouterOutlet], templateUrl: './app.component.html', styleUrl: './app.component.css' }) export class AppComponent { title = 'XYZCARS'; } welcome.component.ts import { Component } from '@angular/core'; @Component({ selector: 'app-welcome', templateUrl: './welcome.component.html', styleUrl: './welcome.component.css' }) export class WelcomeComponent { car = 'toyota'; } 我的项目最初没有 app.module.ts 文件。我自己添加了它并根据网上找到的一些信息进行了配置,但问题仍然存在并且仍未解决。谁能帮我解决这个问题吗? app.module.ts import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { WelcomeComponent } from './welcome/welcome.component'; import { AppComponent } from './app.component'; @NgModule({ declarations: [ AppComponent, WelcomeComponent ], imports: [ BrowserModule ], providers: [], bootstrap: [AppComponent] }) export class AppModule { } 如果您正在 Angular 17 中创建项目->使用这些命令 ng app --no-standalone 然后你就得到了 app.module.ts 文件。


在使用 TypeScript 进行 React 时,输入字段在“值”处给出错误

从“react”导入{SetStateAction,useState} const 登录表单 =() =>{ const [名称,setName] = useState(); const [全名,setFullname] = useState import { SetStateAction, useState } from "react" const Loginform =() =>{ const [name, setName] = useState<String | null>(); const [fullname, setFullname] = useState<String | null>(); const inputEvent =(event: { target: { value: SetStateAction< String |null | undefined >; }; })=>{ setName(event.target.value) } const Submit = ()=>{ setFullname(name) } return <> <h1>Enter Your Name </h1> <input type="text" placeholder="Enter your name" onChange={inputEvent} value={name}/> <button onClick={Submit}>Submit</button> <h1>Hi {fullname==null? "Guest" :fullname}</h1> </> } export default Loginform <input type="text" placeholder="Enter your name" onChange={inputEvent} value={name}/> 上一行中的“value”属性显示错误 这是错误详细信息: (property) React.InputHTMLAttributes<HTMLInputElement>.value?: string | number | readonly string[] | undefined Type 'String | null | undefined' is not assignable to type 'string | number | readonly string[] | undefined'. Type 'null' is not assignable to type 'string | number | readonly string[] | undefined'.ts(2322) index.d.ts(2398, 9): The expected type comes from property 'value' which is declared here on type 'DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>' 也尝试写 return as any。或者尝试添加 string[],但出现错误。 进行以下调整: 将 String 替换为 string,因为原始 Typescript 类型是小写的 (number, string, boolean, etc) TypeScript 报告此错误,因为属性值不接受 null 作为值,而是接受 undefined。将代码更新为: const [name, setName] = useState<string>() 这会使用 string 作为默认类型来初始化状态。 初始状态隐式地被视为 undefined,因为如果未显式提供,TypeScript 会将类型的默认值设置为 undefined。 为了简单起见,您不需要解构事件。使用内联函数,如下例所示: <input type="text" placeholder="Enter your name" onChange={(e) => setName(e.target.value)} value={name}/> 我使用你的代码创建了一个 CodeSanbox,它似乎只需要很少的修改就可以正常工作。 您可以在这里找到沙盒 这是我想出的代码 import { SetStateAction, useState } from "react"; const Loginform = () => { const [name, setName] = useState<string | null>(); const [fullname, setFullname] = useState<string | null>(); const inputEvent = (event: { target: { value: SetStateAction<string | null | undefined> }; }) => { setName(event.target.value); }; const Submit = () => { setFullname(name); }; return ( <div> <h1>Enter Your Name </h1> <input type="text" placeholder="Enter your name" onChange={inputEvent} value={name} /> <button onClick={Submit}>Submit</button> <h1>Hi {fullname == null ? "Guest" : fullname}</h1> </div> ); }; export default Loginform;


如何在 HTMX 中停止轮询? 286并不能阻止htmx继续轮询

根据 HTMX 文档,轮询应在收到响应代码 286 后停止。 鉴于此代码: 根据 HTMX 文档,轮询应在收到响应代码 286 后停止。 给出这段代码: <form id="board" hx-post="/xxx/start" hx-select="#board" hx-trigger="every 1ms" hx-swap="outerHTML" > 我的服务器响应 286 代码: 为什么它继续 ping 我的服务器? 在旧的 reddit 线程中找到答案 顺便说一下,我使用 hx-swap:outerHTML 遇到了一个问题,其中 286 状态代码没有停止轮询,因为 hx 元素是刷新的一部分。我想我可以在里面嵌套另一个 div 并选择该元素来修复这个问题。 回想起来,这很有意义。 解决方案: <form id="board" hx-post="/xxx/start" hx-trigger="every 500ms" hx-select="#board-content" hx-target="#board-content" hx-swap="outerHTML" > <div id="gameoflife-board-content"> // rest of form </div> </form>


使用 Javascript 更改 HTML 中的文本

如何用 Javascript 替换 HTML 中的文本? 在下面的代码片段中,我需要将文本“作者说”替换为“关于作者”。 谢谢你! 如何用 Javascript 替换 HTML 中的文本? 在下面的代码片段中,我需要将文本“作者说”替换为“关于作者”。 谢谢! <div id="author-info"> <div class="author-image"> <a class="author-avatar" href="https://www.test.com"><img alt=""></a> </div> <div class="author_name_wrap"> <h4 class="author_name"><a href="https://www.test.com/author/">Author say</a></h4> <div class="author_socicons"></div> </div> </div> 要更改 html 标签的内容,请使用 innerHTML 属性: var h4 = document.getElementsByClassName("author_name")[0], target = h4.childNodes[0]; target.innerHTML = "About the author"; 这是代码: document.getElementById("id-of-element").innerHTML = "new text"; <!DOCTYPE html> <html> <body> <p id="id-of-element">This text will be replaced</p> </body> </html> 这非常简单,您只需使用innerText或textcontent,如下例所示 //textConent Method const authorName = document.querySelectorAll('author_name').textContent="Text Here" //innerText Method const authorName = document.querySelectorAll('author_name').innerText="Text Here" 如果您使用jQuery,您可以轻松更改。 $("h4.author_name a").text('关于作者'); 您可以在这里找到详细的文章


如何使用javascript forloop在点击时获取html中data-id的值并返回值

这是我的html {% if t_ques %} 今天 {% 表示 t_... 中的项目 这是我的html <ul class="conversations"> {% if t_ques %} <li class="grouping">Today</li> {% for item in t_ques %} <li class="active"> <a id="convers" class="conversation-button text-[#E8F5FC] my-2" href="{% url 'assistant:continuechat' item.pk %}" data-pk="{{item.pk}}"> <i class="fa fa-message fa-regular"></i> {{item.title| truncatewords:04 }} </a> <div class="fade"></div> <div class="edit-buttons"> <button><i class="fa fa-edit"></i></button> <button class="trash" data-id = "{{item.pk}}"><i class="fa fa-trash"></i></button> </div> </li> {% endfor %} {% endif %} {% if y_ques %} <li class="grouping">Yesterday</li> {% for item in y_ques %} <li> <a id="convers" class="conversation-button text-[#E8F5FC] my-2" href="{% url 'assistant:continuechat' item.pk %}" data-pk="{{item.pk}}"> <i class="fa fa-message fa-regular"></i> {{item.title| truncatewords:04 }} </a> <div class="fade"></div> <div class="edit-buttons"> <button><i class="fa fa-edit"></i></button> <button class="trash" data-id = "{{item.pk}}"><i class="fa fa-trash"></i></button> </div> </li> {% endfor %} {% endif %} {% if s_ques %} <li class="grouping">Previous 7 days</li> {% for item in s_ques %} <li> <a id="convers" class="conversation-button text-[#E8F5FC] my-2" href="{% url 'assistant:continuechat' item.pk %}" data-pk="{{item.pk}}"> <i class="fa fa-message fa-regular"></i> {{item.title| truncatewords:04 }} </a> <div class="fade"></div> <div class="edit-buttons"> <button><i class="fa fa-edit"></i></button> <button class="trash" data-id = "{{item.pk}}"><i class="fa fa-trash"></i></button> </div> </li> {% endfor %} {% endif %} {% if more_s_ques %} <li class="grouping">Previous 30 days</li> {% for item in more_s_ques %} <li> <a id="convers" class="conversation-button text-[#E8F5FC] my-2" href="{% url 'assistant:continuechat' item.pk %}" data-pk="{{item.pk}}"> <i class="fa fa-message fa-regular"></i> {{item.title| truncatewords:04 }} </a> <div class="fade"></div> <div class="edit-buttons"> <button><i class="fa fa-edit"></i></button> <button class="trash" data-id = "{{item.pk}}"><i class="fa fa-trash"></i></button> </div> </li> {% endfor %} {% endif %} </ul> </div> 我一直在尝试使用 JavaScript 单击时获取任何 data-pk 的值,但似乎无法实现。这一直说 currentTarget 未定义,当我用 target 替换它时,它说同样的事情。然后,如果我将其替换为 document.querySelector("#convers"),它只会给出第一个值,无论单击哪个 这是我的 JavaScript const conversationButtons = document.querySelectorAll("#convers"); conversationButtons.forEach(button => { button.addEventListener("click", getId); }); function getId(e){ var idValue = e.currentTarget.getAttribute('data-pk'); console.log(idValue); //output corresponding target-id if(!chat_id){ url = `/chat-previous/${idValue}/` }else{ url = 'initiate-chat/' } return url; } $.ajax({ type: 'POST', url: getId(), data: { message: usermsg, chatId: chat_id, // itemId: item_id, csrfmiddlewaretoken: $('input[name=csrfmiddlewaretoken]').val(), action: 'post' }, success: function(json){ const res = json['chats'] setTimeout(() => { hideTyping(); body.appendChild(mgses(res, "assistant")); scrollToBottomOfResults(); }, 1000); console.log(json) }, error: function(rs, e){ setTimeout(() => { hideTyping(); body.appendChild(setBotResponse("bot")); scrollToBottomOfResults(); }, 600); console.log(rs.error); }, }); 我使用了其他方法,例如 const getId = () => { console.log(document.querySelector(".conversation-button").getAttribute('data-pk')) if(!chat_id){ url = `/chat-previous/${document.querySelector(".conversation-button").getAttribute('data-pk')}/` }else{ url = 'initiate-chat/' } return url; } conversationButtons.forEach(button => { button.addEventListener("click", getId); console.log(button.getAttribute('data-pk')); }); 仍然无法得到我真正想要的。有什么方法可以实现这个目标吗? 委托并使用按钮的类 document.querySelector('.conversations').addEventListener('click', (e) => { let tgt = e.target.closest('.conversation-button'); if (!tgt) return; const idValue = tgt.dataset.pk; console.log(idValue); //output corresponding target-id return chat_id ? 'initiate-chat/' : `/chat-previous/${idValue}/` }) 您做出了多个错误的假设,第一个是您不能有多个具有相同 id 的元素,这将导致您描述的确切行为“它需要第一次出现的 id” 第二件事是你可能想在点击时发出ajax请求,但你构建代码的方式并不能做到这一点。 要解决这些问题,请生成如下 html button.conversation-button button.conversation-button button.conversation-button 然后向所有具有 .conversation-button 类的元素添加一个事件侦听器,并将您的 ajax 调用包装到一个函数中,主要是您已经拥有的函数。 const conversationButtons = document.querySelectorAll(".conversation-button"); conversationButtons.forEach(button => { button.addEventListener("click", doStuff); }); ... function doStuff(e) { $.ajax( ... url: getId(e) ... } function getId(e) { let idValue = e.currentTarget.getAttribute('data-pk'); let url = ...; ... return url; // } 只是一些伪代码让你得到一个想法,祝你好运:)


.NET MAUI、ios UseSafeArea 不工作 StackLayout、VerticalStackLayout 和 Grid

<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Test.Views.Activities.ActivityMapList" xmlns:maps="clr-namespace:Microsoft.Maui.Controls.Maps;assembly=Microsoft.Maui.Controls.Maps" xmlns:sensors="clr-namespace:Microsoft.Maui.Devices.Sensors;assembly=Microsoft.Maui.Essentials" xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls" ios:Page.UseSafeArea="False" Shell.NavBarIsVisible="False" Style="{StaticResource Key=DefaultPage}"> <ContentPage.Content> <StackLayout> <maps:Map VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"> <x:Arguments> <MapSpan> <x:Arguments> <sensors:Location> <x:Arguments> <x:Double>36.9628066</x:Double> <x:Double>-122.0194722</x:Double> </x:Arguments> </sensors:Location> <x:Double>0.01</x:Double> <x:Double>0.01</x:Double> </x:Arguments> </MapSpan> </x:Arguments> </maps:Map> </StackLayout> </ContentPage.Content> </ContentPage> StackLayout 或 Grid 内的地图控件,iOS 的 SafeArea 为 false,如图所示。 你有什么解决办法吗? 我需要在地图上使用网格或堆栈布局 默认情况下.NET MAUI 将考虑安全区域。所以使用特定于平台的UseSafeArea就是禁用安全区域。目前,将 UseSafeArea 设置为 false 不会改变行为(尽管应该如此),这是一个错误。另请参阅 MAUI github 上的问题:https://github.com/dotnet/maui/issues/5856 您还可以设置 IgnoreSafeArea 属性来实现相同的目的。但是,它不再在 .NET 7 中工作,请参阅以下问题:https://github.com/dotnet/maui/issues/12823 要解决您的问题,您需要将 IgnoreSafeArea="True" 添加到您的 Grid 或 StackLayout 并将 ios:Page.UseSafeArea="False" 添加到您的页面。这应该不是必需的,但这是对我有用的解决方法。 有关在 iOS 上禁用安全区域的文档可以在此处找到:https://learn.microsoft.com/en-us/dotnet/maui/ios/platform-specifics/page-safe-area-layout?view=net-毛伊岛-7.0 您可以设置 Page Padding 值来实现。在OnAppearing方法中,设置页面的safeInsets,如下代码: protected override void OnAppearing() { base.OnAppearing(); DeviceSafeInsetsService d = new DeviceSafeInsetsService(); double topArea = d.GetSafeAreaTop(); double bottomArea = d.GetSafeAreaBottom(); var safeInsets = On<iOS>().SafeAreaInsets(); safeInsets.Top = -topArea; safeInsets.Bottom = -bottomArea; Padding = safeInsets; } 要获取 topArea 和 bottomArea 值,您应该编写平台代码。答案末尾附有有关此内容的更详细教程。 首先你可以在Project文件夹中生成一个新的类文件并将其更改为部分类。生成两个部分方法。 public partial class DeviceSafeInsetsService { public partial double GetSafeAreaTop(); public partial double GetSafeAreaBottom(); } 然后在iOS平台生成部分文件并实现。该文件位于 Project/Platform/iOS 文件夹中,我想提一下的是,该文件是一个部分文件,因此命名空间应与上面的文件相同。生成此文件时,请删除命名空间中的 .Platforms.iOS 后缀。 public partial class DeviceSafeInsetsService { public partial double GetSafeAreaBottom() { if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0)) { UIWindow window = UIApplication.SharedApplication.Delegate.GetWindow(); var bottomPadding = window.SafeAreaInsets.Bottom; return bottomPadding; } return 0; } public partial double GetSafeAreaTop() { if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0)) { UIWindow window = UIApplication.SharedApplication.Delegate.GetWindow(); var TopPadding = window.SafeAreaInsets.Top; return TopPadding; } return 0; } } 更多信息,您可以参考如何在.NET MAUI中编写特定于平台的代码和MauiPlatformCode示例代码 希望它对你有用。


为什么我的 hx-trigger 没有使用 from: <css selector> 触发?

我有一个按钮,我想在单击时向服务器发送两个请求。设置是这样的: 我有一个按钮,我想在单击时向服务器发送两个请求。设置是这样的: <button id="add-item" hx-get="some-url" hx-trigger="click" hx-target="#item-form" hx-swap="beforeend" type="button">Add item</button> <br> <div hx-get="some-other-url" hx-trigger="from: #add-item" hx-swap="beforeend"> </div> 我尝试过使用hx-trigger="click from: #add-item,但这也不起作用。 add-item 发送的第一个请求是从服务器正确获取的,但来自 div 的第二个请求根本没有发送。当将 div 的触发器更改为 hx-trigger="click" 之类的内容时,它可以工作(还需要其中的一些内容才能单击)。 语法有问题吗?或者为什么这不起作用? 我已经像这样导入了 HTMX: <script src="https://unpkg.com/[email protected]" integrity="sha384-D1Kt99CQMDuVetoL1lrYwg5t+9QdHe7NLX/SoJYkXDFfX37iInKRy5xLSi8nO7UC" crossorigin="anonymous"></script> 如有任何帮助,我们将不胜感激。 您面临的问题可能与您使用 hx-trigger 属性的方式有关。 HTMX 的 hx-trigger 属性决定什么操作触发对服务器的请求。当您使用 hx-trigger="click from: #add-item" 时,它会尝试侦听来自 ID 为 add-item 的元素的单击事件。然而,似乎是 ID 为 add-item 的按钮触发了请求,而不是 div。 要在单击 ID 为 add-item 的按钮时发送两个请求,您可以按如下方式设置 HTMX 属性: <button id="add-item" hx-get="some-url" hx-trigger="click" hx-target="#item-form" hx-swap="beforeend" hx-trigger-boost="true" type="button">Add item</button> <br> <div hx-get="some-other-url" hx-trigger="click: #add-item" hx-swap="beforeend" hx-trigger-boost="true"> </div> 以下是更改内容: 向两个元素添加了 hx-trigger-boost="true"。这确保了 当触发事件传播到父元素(div)时 单击按钮。 将 hx-trigger 上的 div 更改为 hx-trigger="click: #add-item"。这 意味着 div 将监听来自元素的点击事件 ID add-item. 完成这些更改后,当您单击“添加项目”按钮时,它将 按预期触发两个请求。 这解决了问题: hx-trigger="from: #add-item" 替换为 hx-trigger="click from:#add-item" 通过编写 click 来指定事件是必要的,并删除 from: 和 #add-item 之间的空格。


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"));


选中/取消选中 mat-checkbox 未正确返回 true 或 false

我正在使用 Angular 15 和 Angular Material 14,下面是我用来显示复选框列表的 HTML 代码 我正在 Angular 15 和 Angular Material 14 工作,下面是我用来显示复选框列表的 HTML 代码 <div *ngFor="let control of checkboxArray.controls;let i = index" > <mat-checkbox [formControl]="control" (input)="validateInputs(notificationForm)" [checked]="control.value" (change)="control.checked=$event.checked;onCheckedChange(i);"> {{ checkboxItems[i].name }} </mat-checkbox> </div> 下面是Angular中onCheckedChange函数的代码 onCheckedChange(index: number) { this.sortCheckboxArray(); const checkboxItem = this.checkboxItems[index]; const control = this.checkboxArray.at(index); if (control) { if (control.value) { this.lists.push(checkboxItem.id.toString()); } else { this.lists.pop(checkboxItem.id.toString()); } } this.updateSubscriberGroupsCount(); this.cdr.detectChanges(); } 当我选中复选框时,在这个 onCheckedChange 函数中,control.value 始终返回 false。哪里出了问题?无法理解.. 这是一个工作版本,复选框逻辑工作正常,希望有帮助! 我们需要使用control.value获取表单组,但我们还需要访问内部表单控件,然后获取复选框值! import { CommonModule } from '@angular/common'; import { Component } from '@angular/core'; import { FormArray, FormControl, FormGroup, ReactiveFormsModule, } from '@angular/forms'; import { bootstrapApplication } from '@angular/platform-browser'; import 'zone.js'; import { MatCheckboxModule } from '@angular/material/checkbox'; @Component({ selector: 'app-root', standalone: true, imports: [CommonModule, ReactiveFormsModule, MatCheckboxModule], template: ` <form [formGroup]="form"> <div formArrayName="array"> <div *ngFor="let control of checkboxArray.controls;let i = index" [formGroupName]="i"> <mat-checkbox formControlName="test" style="margin-bottom: 15px;" (change)="onCheckedChange(i);"> {{ checkboxItems[i].name }} </mat-checkbox> </div> </div> </form> `, }) export class App { name = 'Angular'; form = new FormGroup({ array: new FormArray([]), }); lists = []; checkboxItems: any = []; ngOnInit() { this.add(); this.add(); this.add(); } add() { this.checkboxArray.push( new FormGroup({ test: new FormControl(false), }) ); this.checkboxItems.push({ name: 'test' }); } get checkboxArray() { return this.form.get('array') as FormArray; } onCheckedChange(index: number) { // this.sortCheckboxArray(); // const checkboxItem = this.checkboxItems[index]; const control = this.checkboxArray.at(index); if (control) { if (control.value.test) { console.log('checked'); // this.lists.push(checkboxItem.id.toString()); } else { console.log('not checked'); // this.lists.pop(checkboxItem.id.toString()); } } // this.updateSubscriberGroupsCount(); // this.cdr.detectChanges(); } } bootstrapApplication(App); 堆栈闪电战


Bootstrap 5 中的选项卡未更改

我有一个引导选项卡区域,并使用 Javascript 在选项卡之间切换。 javascript 被调用但不会更改选项卡。 $('#tabList b...</desc> <question vote="0"> <p>我有一个引导选项卡区域,并使用 Javascript 在选项卡之间切换。 javascript 被调用但不会更改选项卡。</p> <p></p><div data-babel="false" data-lang="js" data-hide="false" data-console="true"> <div> <pre><code>&lt;script type=&#34;text/javascript&#34;&gt; $(&#39;#tabList button&#39;).click ( function (e) { e.preventDefault(); // bootstrap.Tab.getInstance(this).show() $(this).tab(&#39;show&#39;) } ); &lt;/script&gt;</code></pre> <pre><code>&lt;ul class=&#34;nav nav-tabs&#34; id=&#34;tabList&#34; role=&#34;tablist&#34;&gt; &lt;li class=&#34;nav-item&#34; role=&#34;presentation&#34;&gt; &lt;button class=&#34;nav-link&#34; id=&#34;jobs-tab&#34; data-bs-toggle=&#34;tab&#34; data-bs-target=&#34;#jobs&#34; type=&#34;button&#34; role=&#34;tab&#34; aria-controls=&#34;jobs&#34; aria-selected=&#34;true&#34;&gt;[tabHeaderJobs]&lt;/button&gt; &lt;/li&gt; &lt;li class=&#34;nav-item&#34; role=&#34;presentation&#34;&gt; &lt;button class=&#34;nav-link active&#34; id=&#34;employees-tab&#34; data-bs-toggle=&#34;tab&#34; data-bs-target=&#34;#employees&#34; type=&#34;button&#34; role=&#34;tab&#34; aria-controls=&#34;employees&#34; aria-selected=&#34;false&#34;&gt;[tabHeaderEmployees]&lt;/button&gt; &lt;/li&gt; &lt;/ul&gt; &lt;div class=&#34;tabContent&#34; id=&#34;tabContent&#34;&gt; &lt;div class=&#34;tab-pane fade&#34; id=&#34;jobs&#34; role=&#34;tabpanel&#34; aria-labelledby=&#34;jobs-tab&#34;&gt;[tabContentJobs]&lt;/div&gt; &lt;div class=&#34;tab-pane fade active show&#34; id=&#34;employees&#34; role=&#34;tabpanel&#34; aria-labelledby=&#34;employees-tab&#34;&gt;[tabContentEmployees]&lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> <p></p> <p>´´´</p> <p>主选择器是 tabList 还是 tabContent ?</p> <p>那么我是否需要从按钮中选择切换名称,然后使用 <pre><code>($(&#39;#tabContent a[href=&#34;#toggleNameOfTab&#34;]&#39;).tab(&#39;show&#39;)</code></pre> ?</p> </question> <answer tick="false" vote="0"> <p>根据您更新的代码,有几件事:</p> <ol> <li>无需选择<pre><code>#tabContent a</code></pre>。您的选项卡按钮已经具有 <pre><code>.nav-link</code></pre> 类,因此您可以将单击处理程序直接附加到这些按钮:</li> </ol> <pre><code>$(&#39;.nav-link&#39;).click(function() { $(this).tab(&#39;show&#39;); }); </code></pre> <ol start="2"> <li>要以编程方式激活页面加载时的特定选项卡,您可以执行以下操作:</li> </ol> <pre><code>$(&#39;#employees-tab&#39;).tab(&#39;show&#39;); </code></pre> <p>这将在加载时激活#employees-tab。</p> <p>需要了解的关键事项:</p> <ul> <li>使用 <pre><code>.nav-link</code></pre> 将点击处理程序附加到选项卡按钮</li> <li>使用 <pre><code>$(selector).tab(&#39;show&#39;)</code></pre> 以编程方式切换选项卡,其中 <pre><code>selector</code></pre> 是选项卡按钮的 ID 或元素</li> </ul> </answer> </body></html>


如何防止点击时嵌套 React 组件中的事件冒泡?

这是一个基本组件。 和 都有 onClick 函数。我只想触发 上的 onClick,而不是 。我怎样才能实现这个目标? 我玩过 这是一个基本组件。 <ul> 和 <li> 都有 onClick 函数。我只想触发 <li> 上的 onClick,而不是 <ul>。我怎样才能实现这个目标? 我尝试过 e.preventDefault()、e.stopPropagation(),但无济于事。 class List extends React.Component { constructor(props) { super(props); } handleClick() { // do something } render() { return ( <ul onClick={(e) => { console.log('parent'); this.handleClick(); }} > <li onClick={(e) => { console.log('child'); // prevent default? prevent propagation? this.handleClick(); }} > </li> </ul> ) } } // => parent // => child 我也有同样的问题。我发现 stopPropagation did 有效。我会将列表项拆分为一个单独的组件,如下所示: class List extends React.Component { handleClick = e => { // do something } render() { return ( <ul onClick={this.handleClick}> <ListItem onClick={this.handleClick}>Item</ListItem> </ul> ) } } class ListItem extends React.Component { handleClick = e => { e.stopPropagation(); // <------ Here is the magic this.props.onClick(); } render() { return ( <li onClick={this.handleClick}> {this.props.children} </li> ) } } React 使用事件委托和文档上的单个事件侦听器来处理冒泡事件,例如本例中的“单击”,这意味着不可能停止传播;当您在 React 中与真实事件交互时,真实事件已经传播。 React 的合成事件上的 stopPropagation 是可能的,因为 React 在内部处理合成事件的传播。 stopPropagation: function(e){ e.stopPropagation(); e.nativeEvent.stopImmediatePropagation(); } 关于 DOM 事件的顺序:CAPTURING vs BUBBLING 事件传播有两个阶段。这些被称为 “捕获” 和 “冒泡”。 | | / \ ---------------| |----------------- ---------------| |----------------- | element1 | | | | element1 | | | | -----------| |----------- | | -----------| |----------- | | |element2 \ / | | | |element2 | | | | | ------------------------- | | ------------------------- | | Event CAPTURING | | Event BUBBLING | ----------------------------------- ----------------------------------- 首先发生捕获阶段,然后是冒泡阶段。当您使用常规 DOM api 注册事件时,默认情况下事件将成为冒泡阶段的一部分,但这可以在事件创建时指定 // CAPTURING event button.addEventListener('click', handleClick, true) // BUBBLING events button.addEventListener('click', handleClick, false) button.addEventListener('click', handleClick) 在React中,冒泡事件也是你默认使用的。 // handleClick is a BUBBLING (synthetic) event <button onClick={handleClick}></button> // handleClick is a CAPTURING (synthetic) event <button onClickCapture={handleClick}></button> 让我们看一下handleClick回调(React): function handleClick(e) { // This will prevent any synthetic events from firing after this one e.stopPropagation() } function handleClick(e) { // This will set e.defaultPrevented to true // (for all synthetic events firing after this one) e.preventDefault() } 我在这里没有看到提到的替代方案 如果您在所有事件中调用 e.preventDefault(),您可以检查事件是否已被处理,并防止再次处理它: handleEvent(e) { if (e.defaultPrevented) return // Exits here if event has been handled e.preventDefault() // Perform whatever you need to here. } 关于合成事件和原生事件的区别,请参阅React文档:https://reactjs.org/docs/events.html 这是防止单击事件前进到下一个组件然后调用 yourFunction 的简单方法。 <Button onClick={(e)=> {e.stopPropagation(); yourFunction(someParam)}}>Delete</Button> 这不是 100% 理想,但如果在儿童中传递 props 太痛苦 -> 儿童时尚或为此目的创建 Context.Provider/Context.Consumer just),你正在处理另一个库,它有自己的处理程序,它在您的处理程序之前运行,您也可以尝试: function myHandler(e) { e.persist(); e.nativeEvent.stopImmediatePropagation(); e.stopPropagation(); } 据我了解,event.persist方法可以防止对象立即被扔回React的SyntheticEvent池中。因此,当你伸手去拿 React 中传递的 event 时,它实际上并不存在!这种情况发生在孙子中,因为 React 在内部处理事情的方式是首先检查父进程是否有 SyntheticEvent 处理程序(特别是如果父进程有回调)。 只要您不调用 persist 来创建大量内存以继续创建诸如 onMouseMove 之类的事件(并且您没有创建某种 Cookie Clicker 游戏,例如 Grandma's Cookies),就应该完全没问题! 另请注意:偶尔阅读他们的 GitHub,我们应该密切关注 React 的未来版本,因为他们可能最终会解决一些问题,因为他们似乎打算在编译器中折叠 React 代码/转译器。 如果您希望发生嵌套元素中的操作而不是父元素中的操作,那么,您可以从父元素的操作处理程序中检查目标的类型,然后基于该类型执行操作,即,如果目标是我们的嵌套元素,我们什么也不做。否则两个处理程序都会被调用。 // Handler of the parent element. Let's assume the nested element is a checkbox function handleSingleSelection(e) { if(e.target.type !== 'checkbox') { // We do not do anything from the // parent handler if the target is a checkbox ( our nested element) // Note that the target will always be the nested element dispatch(lineSelectionSingle({ line })) } } 我在 event.stopPropagation() 工作时遇到问题。如果您也这样做,请尝试将其移动到单击处理程序函数的顶部,这就是我需要做的来阻止事件冒泡。示例函数: toggleFilter(e) { e.stopPropagation(); // If moved to the end of the function, will not work let target = e.target; let i = 10; // Sanity breaker while(true) { if (--i === 0) { return; } if (target.classList.contains("filter")) { target.classList.toggle("active"); break; } target = target.parentNode; } } 您可以通过检查事件目标来避免事件冒泡。 例如,如果您将输入嵌套到 div 元素,其中有单击事件的处理程序,并且您不想处理它,则单击输入时,您可以将 event.target 传递到您的处理程序中,并检查处理程序应该是根据目标的属性执行。 例如,您可以检查 if (target.localName === "input") { return}。 所以,这是一种“避免”处理程序执行的方法 解决此问题的另一种方法可能是在子级上设置 onMouseEnter 和 onMouseLeave 事件。 (您的 < li > 标签) 每当鼠标悬停在子级上时,您都可以设置一个特定的状态,以阻止父级执行 onClick 函数内容。 比如: class List extends React.Component { constructor(props) { super(props) this.state.overLi = false } handleClick() { // do something } render() { return ( <ul onClick={(e) => { if (!this.state.overLi) { console.log("parent") this.handleClick() } }} > <li onClick={(e) => { console.log("child") // prevent default? prevent propagation? this.handleClick() }} onMouseEnter={() => this.setState({ overLi: true, }) } onMouseLeave={() => this.setState({ overLi: false, })} ></li> </ul> ) } } 我进行了很多搜索,但没有设法使用 e.stopPropagation() 为我的上下文实现任何解决方案 您可以验证点击的元素是否是预期的元素。 例如: class List extends React.Component { constructor(props) { super(props); } handleClick(e) { if(e.target.className==='class-name'){ // do something } } render() { return ( <ul {/* Replace this with handleClick */} onClick={(e) => { console.log('parent'); this.handleClick(); }} <li onClick={(e) => { console.log('child'); // prevent default? prevent propagation? this.handleClick(); }} </li> </ul> ) } } 执行此操作的新方法更加简单,并且会节省您一些时间!只需将事件传递到原始点击处理程序并调用 preventDefault();。 clickHandler(e){ e.preventDefault(); //Your functionality here }


使用python的mechanize自动网站登录

我正在尝试自动登录一个网站,该网站的登录表单具有以下 HTML 代码(摘录): 我正在尝试自动登录一个网站,其登录表单具有以下 HTML 代码(摘录): <tr> <td width="60%"> <input type="text" name="username" class="required black_text" maxlength="50" value="" /> </td> <td> <input type="password" name="password" id="password" class="required black_text" maxlength="50" value="" /> </td> <td colspan="2" align="center"> <input type="image" src="gifs/login.jpg" name="Login2" value="Login" alt="Login" title="Login"/> </td> </tr> 我正在使用python的mechanize模块进行网页浏览。以下是代码: br.select_form(predicate=self.__form_with_fields("username", "password")) br['username'] = self.config['COMMON.USER'] br['password'] = self.config['COMMON.PASSWORD'] try: request = br.click(name='Login2', type='image') response = mechanize.urlopen(request) print response.read() except IOError, err: logger = logging.getLogger(__name__) logger.error(str(err)) logger.debug(response.info()) print str(err) sys.exit(1) def __form_with_fields(self, *fields): """ Generator of form predicate functions. """ def __pred(form): for field_name in fields: try: form.find_control(field_name) except ControlNotFoundError, err: logger = logging.getLogger(__name__) logger.error(str(err)) return False return True return __pred 不知道我做错了什么...... 谢谢 该网站有可能在登录期间使用java脚本进行回发。我记得很清楚,对于 ASP .Net 站点,您需要获取隐藏表单字段,例如 VIEWSTATE 和 EVENTTARGET 并将它们发布到新 Page 。 您为什么不发送问题网站的链接?之后就变得相对容易弄清楚了 尝试使用 Selenium 和 PhantomJS from selenium import PhantomJS import platform if platform.system() == 'Windows': # .exe for Windows PhantomJS_path = './phantomjs.exe' else: PhantomJS_path = './phantomjs' service_args = [ # Proxy (optional) '--proxy=<>', '--proxy-type=http', '--ignore-ssl-errors=true', '--web-security=false' ] browser = PhantomJS(PhantomJS_path, service_args=service_args) browser.set_window_size(1280, 720) # Window size for screenshot (optional) login_url = "<url_here>" # Credentials Username = "<insert>" Password = "<insert>" # Login browser.get(login_url) browser.save_screenshot('login.png') print browser.current_url browser.find_element_by_id("<username field id>").send_keys(Username) browser.find_element_by_id("<password field id>").send_keys(Password) browser.find_element_by_id("<login button id>").click() print (browser.current_url) browser.get(scrape_url) print browser.page_source browser.quit() ''' python 和 pycharm 设置路径变量 点维辛检查 包管理器 python 如何安装新版本 python最新版本 - python 3.7.2 用户环境变量 蟒蛇 pyton 中的命令行 '''


QWebEngineView:html 文件中的 href 不起作用

我有一个 test.html 文件,例如: 我有一个 test.html 文件,例如: <!DOCTYPE html> <html> <head> </head> <body> <a style="padding-right:5px" target="_blank" href="data/">Datadir</a> </body> </html> 包含 test.html 的目录如下: test.html data\ a.txt b.txt 我使用“file:///remote/us01home19/ktc/public_html/testLocalHref/test.html”并在firefox和chrome中单击Datadir,结果如下: 和: 我写了一个pyside2代码来做同样的事情,代码如下: from PySide2 import QtCore, QtWidgets, QtWebEngineWidgets import os import sys class CustomWebEnginePage(QtWebEngineWidgets.QWebEnginePage): # Store second window. external_window = None def acceptNavigationRequest(self, url, _type, isMainFrame): print(url, _type, isMainFrame) if _type == QtWebEngineWidgets.QWebEnginePage.NavigationTypeLinkClicked: if not self.external_window: self.external_window = QtWebEngineWidgets.QWebEngineView() self.external_window.setUrl(url) self.external_window.show() return False return super().acceptNavigationRequest(url, _type, isMainFrame) class MainWindow(QtWidgets.QMainWindow): def __init__(self, *args, **kwargs): super(MainWindow, self).__init__(*args, **kwargs) self.browser = QtWebEngineWidgets.QWebEngineView() self.browser.setPage(CustomWebEnginePage(self)) # self.browser.setUrl(QtCore.QUrl("https://code.visualstudio.com")) self.browser.setUrl(QtCore.QUrl("file:///remote/us01home19/ktc/public_html/testLocalHref/test.html")) # self.browser.setUrl(QtCore.QUrl("file:///remote/tw_rnd1/ktc/prog/python/pyside2/WebEngine/data/aaa.ava.summary.html")) #self.browser.setUrl(QtCore.QUrl("file:///remote/tw_rnd1/ktc/prog/python/pyside2/WebEngine/data/aaa_ava_corners/C_1")) self.setCentralWidget(self.browser) if __name__ == '__main__': app = QtWidgets.QApplication(sys.argv) window = MainWindow() window.show() sys.exit(app.exec_()) 但是执行代码,我得到的结果如下: 但是点击Datadir,没有任何反应,甚至QWebEnginePage.acceptNavigationRequest也没有触发。有没有办法让 QWebEngine 的行为像 Firefox 和 Chrome 一样? 我尝试在 QWebEnginePage.acceptNavigationRequest 函数中添加打印消息来捕获点击 dataDir 信息,但似乎没有任何响应。 python版本:python-3.9.0, 操作系统版本:“CentOS Linux 7”, Qt 版本:“Qt_5.15” python 和 Qt 是自定义构建 我发现问题来自htmltarget =“_blank”在QWebEnginePage中不起作用,它可以通过在QtWebEngineWidgets中实现类函数createWindow来避免,例如: class CustomWebEnginePage(QtWebEngineWidgets.QWebEnginePage): # Store second window. external_window = None def acceptNavigationRequest(self, url, _type, isMainFrame): print(url, _type, isMainFrame) if _type == QtWebEngineWidgets.QWebEnginePage.NavigationTypeLinkClicked: if not self.external_window: self.external_window = QtWebEngineWidgets.QWebEngineView() self.external_window.setUrl(url) self.external_window.show() return False return super().acceptNavigationRequest(url, _type, isMainFrame) def createWindow(self, t): return self;enter code here


何时切换搜索栏和徽标下降?

.navbar { 背景颜色:#F91F46; } .src-bar { 边框:0; 边框半径:5px; 概要:无; 左内边距:15px; 宽度:30vw; } .navbar { background-color: #F91F46; } .src-bar { border: 0; border-radius: 5px; outline: none; padding-left: 15px; width: 30vw; } <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.2/css/bootstrap.min.css" integrity="sha512-b2QcS5SsA8tZodcDtGRELiGv5SaKSk1vDHDaQRda0htPYWZ6046lr3kJ5bAAQdpV2mmA/4v0wQF9MyU6/pDIAg==" crossorigin="anonymous" referrerpolicy="no-referrer" /> <script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.2/js/bootstrap.min.js" integrity="sha512-WW8/jxkELe2CAiE4LvQfwm1rajOS8PHasCCx+knHG0gBHt8EXxS6T6tJRTGuDQVnluuAvMxWF4j8SNFDKceLFg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <nav class="navbar navbar-expand-md fixed-top"> <div class="container-fluid"> <a class="navbar-brand ms-3" href="#"> <img src="img/Logo.avif" width="40px" class="d-inline-block" /> </a> <form role="search" class="search-bar"> <div class="input-group"> <input class="src-bar" type="search" placeholder="Search For Products" /> <button class="btn bg-white" type="submit"> <i class="fa fa-search"></i> </button> </div> </form> <div class="justify-content-end"> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#nav-colps" aria-controls="nav-colps" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="nav-colps"> <ul class="navbar-nav me-auto mb-2 mb-lg-0"> <li class="nav-item"> <a class="nav-link active" aria-current="page" href="#">Home</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Link</a> </li> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown </a> <ul class="dropdown-menu" aria-labelledby="navbarDropdown"> <li><a class="dropdown-item" href="#">Action</a></li> <li><a class="dropdown-item" href="#">Another action</a></li> <li> <hr class="dropdown-divider" /> </li> <li><a class="dropdown-item" href="#">Something else here</a></li> </ul> </li> <li class="nav-item"> <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a> </li> </ul> </div> </div> </div> </nav> 切换时,我希望折叠 div 居中。我知道原因 - 我将折叠和切换 btn 放在 justify-end div 内,因为我需要切换 btn 位置位于右侧。现在,当切换时,我的折叠位于右侧,但我希望在切换时,折叠div到中心。 当我删除 justify-end div 时,它位于左侧,但如果删除它,每个导航元素都会移动到 nav 和 md 视图中 lg 的左侧。 看起来像这样或中心 我们确实需要将 .nav-collapse 移到 justify-end 元素之外,才能在较窄的视口上获得所需的布局。 要将菜单显示在右侧,请通过 flex-grow: 1 类将 .nav-collapse 应用于 flex-grow: 0 元素,覆盖 flex-grow-0 上的默认 .nav-collapse。 为了使窄视口的链接元素居中,.navbar-nav中的元素采用垂直柔性布局,因此我们可以通过align-items: center类应用align-items-center: .navbar { background-color: #F91F46; } .src-bar { border: 0; border-radius: 5px; outline: none; padding-left: 15px; width: 30vw; } <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.2/css/bootstrap.min.css" integrity="sha512-b2QcS5SsA8tZodcDtGRELiGv5SaKSk1vDHDaQRda0htPYWZ6046lr3kJ5bAAQdpV2mmA/4v0wQF9MyU6/pDIAg==" crossorigin="anonymous" referrerpolicy="no-referrer" /> <script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.2/js/bootstrap.min.js" integrity="sha512-WW8/jxkELe2CAiE4LvQfwm1rajOS8PHasCCx+knHG0gBHt8EXxS6T6tJRTGuDQVnluuAvMxWF4j8SNFDKceLFg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <nav class="navbar navbar-expand-md fixed-top"> <div class="container-fluid"> <a class="navbar-brand ms-3" href="#"> <img src="https://picsum.photos/40/40" width="40px" class="d-inline-block" /> </a> <form role="search" class="search-bar"> <div class="input-group"> <input class="src-bar" type="search" placeholder="Search For Products" /> <button class="btn bg-white" type="submit"> <i class="fa fa-search"></i> </button> </div> </form> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#nav-colps" aria-controls="nav-colps" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse flex-grow-0" id="nav-colps"> <ul class="navbar-nav me-auto mb-2 mb-lg-0 align-items-center"> <li class="nav-item"> <a class="nav-link active" aria-current="page" href="#">Home</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Link</a> </li> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown </a> <ul class="dropdown-menu" aria-labelledby="navbarDropdown"> <li><a class="dropdown-item" href="#">Action</a></li> <li><a class="dropdown-item" href="#">Another action</a></li> <li> <hr class="dropdown-divider" /> </li> <li><a class="dropdown-item" href="#">Something else here</a></li> </ul> </li> <li class="nav-item"> <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a> </li> </ul> </div> </div> </nav> 您还可以考虑通过 text-align: center 类应用 text-center,将链接元素 text 居中: .navbar { background-color: #F91F46; } .src-bar { border: 0; border-radius: 5px; outline: none; padding-left: 15px; width: 30vw; } <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.2/css/bootstrap.min.css" integrity="sha512-b2QcS5SsA8tZodcDtGRELiGv5SaKSk1vDHDaQRda0htPYWZ6046lr3kJ5bAAQdpV2mmA/4v0wQF9MyU6/pDIAg==" crossorigin="anonymous" referrerpolicy="no-referrer" /> <script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.2/js/bootstrap.min.js" integrity="sha512-WW8/jxkELe2CAiE4LvQfwm1rajOS8PHasCCx+knHG0gBHt8EXxS6T6tJRTGuDQVnluuAvMxWF4j8SNFDKceLFg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <nav class="navbar navbar-expand-md fixed-top"> <div class="container-fluid"> <a class="navbar-brand ms-3" href="#"> <img src="https://picsum.photos/40/40" width="40px" class="d-inline-block" /> </a> <form role="search" class="search-bar"> <div class="input-group"> <input class="src-bar" type="search" placeholder="Search For Products" /> <button class="btn bg-white" type="submit"> <i class="fa fa-search"></i> </button> </div> </form> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#nav-colps" aria-controls="nav-colps" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse flex-grow-0" id="nav-colps"> <ul class="navbar-nav me-auto mb-2 mb-lg-0 text-center"> <li class="nav-item"> <a class="nav-link active" aria-current="page" href="#">Home</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Link</a> </li> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown </a> <ul class="dropdown-menu" aria-labelledby="navbarDropdown"> <li><a class="dropdown-item" href="#">Action</a></li> <li><a class="dropdown-item" href="#">Another action</a></li> <li> <hr class="dropdown-divider" /> </li> <li><a class="dropdown-item" href="#">Something else here</a></li> </ul> </li> <li class="nav-item"> <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a> </li> </ul> </div> </div> </nav>


脚本无法在我的引导模式中工作

希望这不是一个愚蠢的问题,但我已经没有主意了...... 所以我有这个模式: 1.scala.html 希望这不是一个愚蠢的问题,但我已经没有主意了...... 所以我有这个模式: 1.scala.html <div class="feat" id="cor" data-toggle="tooltip" data-placement="bottom" title="add conference role"><div data-toggle="modal" data-target="#conf-role-menu-modal">Conference Role</div></div> <div class="modal fade" id="conf-role-menu-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <h4 class="modal-title" id="myModalLabel">Modal title</h4> </div> <div class="modal-body-conf-role-menu"> <script type="text/javascript"> $(function(){ $(".modal-body-conf-role-menu").load("@routes.Application.areaConferenceRole(id,idenv)"); }); </script> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div> </div> </div> 使用模态主体中的脚本,我尝试加载此页面: 2.scala.html @(id:String, idenv:String) @Main("Add area") { <form action="@routes.Application.areaPostConferenceRole(id,idenv)" method="POST"> First Name: <input type="text" name="first_name" id="first" class="form-control"> Last Name : <input name="last_name" class="form-control"> <script type="text/javascript"> $( document ).ready(function() { // Handler for .ready() called. $( "#first" ).focus(function() { alert( "Handler for .focus() called." ); }); }); </script> </form> } 页面加载正常。我在我的模态中看到它...... 问题是我的页面 2.scala.html 中的脚本无法运行。我不明白为什么......如果我从我尝试在模态中加载的页面之外尝试它们,它们就会起作用...... $( document ).ready(function(){}); 永远不会在模态中到达,因为加载页面时已经触发了此事件(模态在之后加载...) 尝试直接插入脚本,如下所示: <script type="text/javascript"> $( "#first" ).focus(function() { alert( "Handler for .focus() called." ); }); </script> 当引导模式弹出时,shown.bs.modal事件将被触发。这是例子。 $('#myModal').on('shown.bs.modal', function () { $('#myInput').trigger('focus') }) Full documentation. https://getbootstrap.com/docs/4.0/components/modal/ 试试这个我已经准备好这个功能了 $('#myModal').on('shown.bs.modal', function () { // Your script here }); $(document).on('shown.bs.modal', '#myModal', function () { // Your script here });


从 R 导出阿拉伯文本

我正在尝试在 R 中导出包含阿拉伯文本的数据框。 当 R 导入阿拉伯文本时,它将其转换为 UTF-8 代码。像这样: 我正在尝试在 R 中导出包含阿拉伯文本的数据框。 当 R 导入阿拉伯文本时,它会将其转换为 UTF-8 代码。像这样: <U+0627><U+0644><U+0641><U+0631><U+0639> <U+0627><U+0644><U+062A><U+0634><U+0631><U+064A><U+0639><U+064A><U+060C> <U+0627><U+0644><U+0641><U+0631><U+0639> <U+0627><U+0644><U+062A><U+0646><U+0641><U+064A><U+0630><U+064A><U+060C><U+0627><U+0644><U+0641><U+0631><U+0639> <U+0627><U+0644><U+0642><U+0636><U+0627><U+0626><U+064A>. <U+0627><U+0644><U+062D><U+0643><U+0648><U+0645><U+0629> <U+0627><U+0644><U+0641><U+062F><U+0631><U+0627><U+0644><U+064A> 不幸的是,导出时我无法将其转回可读的阿拉伯语。下面是我正在使用的代码... write.csv(my.data,"data.csv", fileEncoding='UTF-8') 有人有解决办法吗? 此外,这是我的会话信息。 R version 3.0.1 (2013-05-16) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] ggplot2_0.9.3.1 loaded via a namespace (and not attached): [1] colorspace_1.2-2 dichromat_2.0-0 digest_0.6.3 grid_3.0.1 gtable_0.1.2 [6] labeling_0.2 MASS_7.3-27 munsell_0.4.2 plyr_1.8 proto_0.3-10 [11] RColorBrewer_1.0-5 reshape2_1.2.2 scales_0.2.3 stringr_0.6.2 tools_3.0.1 这段代码对我有用,所以我分享它: Sys.setlocale("LC_CTYPE", "arabic" ) write.csv(group$message, file = 'posts.txt', fileEncoding = "UTF-8") 如果将文件另存为 csv,它将不起作用。您必须将其另存为txt。 您必须安装并使用语言环境。这很困难,有时甚至不起作用。 这里提供了一些解决方案和代码:写入数据并不保留编码 请记住,您实际上必须为您的操作系统安装语言包,而对于某些 Windows 版本,根本没有任何单独可用的语言包。 这已经晚了 10 年,但我遇到了类似的问题,并决定发布我的解决方案,以防将来对其他人有帮助。 我的解决方案是使用包“openxlsx”。 首先,您需要安装 openxlsx 软件包(如果尚未安装): library(openxlsx) 然后,您可以修改代码以使用 UTF-8 编码编写 xlsx 文件而不是 csv,如下所示: write.xlsx(my.data,"data.xlsx", rowNames = FALSE, showNA = FALSE, encoding = "UTF-8") 希望这对某人有帮助!


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>


我如何根据状态更改按钮颜色(绿色表示“接受”,红色表示“删除”)

如何根据状态更改按钮颜色(绿色表示“接受”,红色表示“删除”) 我是新人,为此使用 Laravel 框架。 这是我的观点 如何根据状态更改按钮颜色(绿色表示“接受”,红色表示“删除”) 我是新人,为此使用 Laravel 框架。 这是我的看法 <table class="table table-striped" id="example"> <thead> <tr> <th>ID no</th> <th>Form Name</th> <th style="text-align: center">Update</th> <th>Delete</th> <th>Status</th> </tr> </thead> @foreach($form as $show) {{--modal--}} <div class="modal fade mj_popupdesign mj_checkoutpopup" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-body"> <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12 col-lg-offset-2 col-md-offset-2"> <div class="row"> <div class="mj_pricingtable mj_greentable mj_login_form_wrapper"> <form> <div class="mj_login_form"> <p>Are you sure you want to delete this post?</p> <br> <a href="" class="mj_btn btn btn-default pull-right glyphicon glyphicon-remove "> No</a> <a href="{{url('deleteForm',$show->id)}}" class=" pull-right mj_btn btn btn-danger glyphicon glyphicon-ok"> Yes</a> </div> </form> </div> </div> </div> </div> </div> </div> </div> {{--end modal--}} <tbody> <tr> <td> <p> {{$show->id}}</p> </td> <td> <h6><a href="{{url('JobDetails',$show->id)}}"style="color: rgb(0, 191, 243);font-size:18px;float: left;margin: 0;text-align: left">{{$show->jobTitle}}</a> </h6> <p> {{$show->created_at}} </p> </td> <td> <a href="{{url('UpdateFormView',$show->id)}}"> <span class="mj_btn btn btn-success">Update</span> </a> </td> <td> <span class="mj_btn btn btn-danger" data-toggle="modal" data-target="#myModal2">Delete</span> </td> <td><span class="mj_btn btn btn-warning">pending</span> </td> </tr> </tbody> @endforeach </table> </div> </div> </div> </div> 在我的控制器中public function AcquiredForm() { $acquired="Requirement Form"; $acquireForm=Job::where('jobType','LIKE','%'.$acquired.'%'); $form = $acquireForm->get(); return view('private-pages.company.aquire-form',compact('form')); } 数据库状态默认为待处理 数据库状态默认为pending 我在代码中没有看到 status 属性,但显示状态为待处理的纯字符串 <span class="mj_btn btn btn-warning">pending</span> <!-- while it suppose to be --> <span class="mj_btn btn btn-warning">{{ $show->status }}</span> 假设它确实存在,你可以做 <td> @if ($show->status === 'Accept') <span class="mj_btn btn btn-green">Accepted</span> @elseif ($show->status === 'Delete') <span class="mj_btn btn btn-danger">Deleted</span> @else <span class="mj_btn btn btn-warning">Pending</span> @endif </td> 参见:https://laravel.com/docs/5.1/blade#displaying-data <td> @if ($show->jobstatus === "Accepted") <span class="mj_btn btn btn-success">Accepted</span> @elseif ($show->jobstatus === "Rejected") <span class="mj_btn btn btn-danger">Rejected</span> @else <span class="mj_btn btn btn-warning">Pending</span> @endif </td> 或者当你使用 1. laravel esialy customaize this code nad add automatic refresh in the page to more interactive @php if($da->status == "requested") { echo "<td><button class='btn btn-primary'>Requested</button></td>"; } else { echo "<td><button class='btn btn-success'>Ordered</button></td>"; } @endphp


ESLint:解析错误:意外的标记:

大家好我正在将我的 vue3 项目从 js 迁移到 typescript,我遇到了这个问题: 这是我在 .vue 文件中的代码 const toto = (msg: string) => { </desc> <question vote="7"> <p>大家好,我正在将我的 vue3 项目从 js 迁移到 typescript,我遇到了这个问题:</p> <p><a href="https://i.stack.imgur.com/y5tG8.png" target="_blank"><img src="https://cdn.txt58.com/i/AWkuc3RhY2suaW1ndXIuY29tL3k1dEc4LnBuZw==" alt=""/></a></p> <p>这是我在 .vue 文件中的代码</p> <pre><code>&lt;script setup lang=&#34;ts&#34;&gt; const toto = (msg: string) =&gt; { console.log(msg) } &lt;/script&gt; </code></pre> <p>这是我的 eslintrc.js</p> <pre><code>module.exports = { &#39;env&#39;: { &#39;browser&#39;: true, &#39;es2021&#39;: true }, &#39;extends&#39;: [ &#39;eslint:recommended&#39;, &#39;plugin:vue/vue3-essential&#39; ], &#39;parserOptions&#39;: { &#39;ecmaVersion&#39;: 13, &#39;sourceType&#39;: &#39;module&#39; }, &#39;plugins&#39;: [ &#39;vue&#39; ], &#39;rules&#39;: { &#39;vue/multi-word-component-names&#39;: &#39;off&#39;, &#39;vue/object-curly-spacing&#39;: [2, &#39;always&#39;], &#39;vue/html-closing-bracket-spacing&#39;: [2, { &#39;selfClosingTag&#39;: &#39;always&#39; }], &#39;vue/max-attributes-per-line&#39;: [2, { &#39;singleline&#39;: { &#39;max&#39;: 1 }, &#39;multiline&#39;: { &#39;max&#39;: 1 } }], &#39;semi&#39;: [2, &#39;never&#39;] } } </code></pre> </question> <answer tick="true" vote="10"> <p>您需要配置 eslint 以支持 typescript,因为 eslint 不支持开箱即用。 首先,您需要安装<a href="https://www.npmjs.com/package/@typescript-eslint/parser" rel="nofollow noreferrer">@typescript-eslint/parser</a>,然后安装<a href="https://www.npmjs.com/package/@typescript-eslint/eslint-plugin" rel="nofollow noreferrer">@typescript-eslint/eslint-plugin</a>。 安装完这些后,请按如下方式更新您的配置 - </p> <pre><code>module.exports = { &#39;env&#39;: { &#39;browser&#39;: true, &#39;es2021&#39;: true, node: true }, &#39;extends&#39;: [ &#39;eslint:recommended&#39;, &#39;plugin:vue/vue3-essential&#39; ], &#39;parserOptions&#39;: { &#39;ecmaVersion&#39;: 12, &#39;sourceType&#39;: &#39;module&#39;, parser: &#39;@typescript-eslint/parser&#39; }, &#39;plugins&#39;: [ &#39;vue&#39;, &#39;@typescript-eslint&#39; ], &#39;rules&#39;: { &#39;vue/multi-word-component-names&#39;: &#39;off&#39;, &#39;vue/object-curly-spacing&#39;: [2, &#39;always&#39;], &#39;vue/html-closing-bracket-spacing&#39;: [2, { &#39;selfClosingTag&#39;: &#39;always&#39; }], &#39;vue/max-attributes-per-line&#39;: [2, { &#39;singleline&#39;: { &#39;max&#39;: 1 }, &#39;multiline&#39;: { &#39;max&#39;: 1 } }], &#39;semi&#39;: [2, &#39;never&#39;] } } </code></pre> </answer> <answer tick="false" vote="1"> <p>就我而言,问题是我使用解析器选项作为数组,而不是字符串:</p> <pre><code> parserOptions: { - parser: [&#39;@typescript-eslint/parser&#39;], + parser: &#39;@typescript-eslint/parser&#39;, }, </code></pre> </answer> <answer tick="false" vote="0"> <p>如果你在项目中同时使用 JS 和 TS,此配置有帮助</p> <pre><code> overrides: [ { files: [&#39;*.vue&#39;], parser: &#39;svelte-eslint-parser&#39;, parserOptions: { parser: { // Specify a parser for each lang. ts: &#39;@typescript-eslint/parser&#39;, js: &#39;espree&#39;, typescript: &#39;@typescript-eslint/parser&#39; } } } ], </code></pre> </answer> <answer tick="false" vote="-1"> <p>我在节点 v12.22.9 上遇到了这个问题。通过升级到 v14.21.2,我不再遇到解析错误。您可以使用命令升级/安装</p> <pre><code>nvm install v14.21.2 </code></pre> </answer> </body></html>


在具有 Open Liberty Dev 模式的 Maven 项目中使用本地库

我有一个 Maven 项目,它构建了一个部署到 Open Liberty 的战争。我正在使用 Liberty maven 插件: io.openliberty.tools 我有一个 Maven 项目,它构建了一个部署到 Open Liberty 的战争。我正在使用 Liberty maven 插件: <plugin> <groupId>io.openliberty.tools</groupId> <artifactId>liberty-maven-plugin</artifactId> <version>3.9</version> <!-- Specify configuration, executions for liberty-maven-plugin --> </plugin> 我正在利用开发模式并且它运行良好。但是,我想在 Dev 模式下使用本地 jar 文件库。 我期望我能够将 jar 文件放置在项目中的特定位置,并且 Liberty 开发模式会自动拾取它们 - 类似于自动拾取 server.xml 的方式src/main/liberty/config。我的 server.xml 设置为在此处查找库:${shared.config.dir}/lib/global,因此我尝试将罐子放入 src/main/liberty/shared/config/lib/global 中,但这不起作用。 我看到的另一种选择是使用 Libity 插件的 copyDependencies 配置。 有一些推荐的方法可以实现我想做的事情吗?理想情况下,我想要最简单的解决方案,既适用于 liberty dev 模式,也适用于 vanilla maven 构建 (mvn package)。 这里的类似问题利用了 copyDependencies 配置,但具体来说,我正在寻找本地 jar 的最佳解决方案(是的,我可以使用系统范围的 Maven 坐标或在本地安装 jar) 如何在 Maven 构建期间将外部依赖项复制到 Open Liberty 谢谢 好问题,稍微概括一下问题,您可能可以使用三种方法: 1.使用资源插件 <build> <resources> <!-- Explicitly configure the default too --> <resource> <directory>${project.basedir}/src/main/resources</directory> </resource> <!-- Custom library --> <resource> <directory>${project.basedir}/mylib</directory> <targetPath>${project.build.directory}/liberty/wlp/usr/shared/lib/global</targetPath> <!-- Default, but just emphasizing the point --> <filtering>false</filtering> </resource> </resources> 由于开发模式在其“生命周期”中调用 resources:resources 目标,因此可以在没有任何插件配置的情况下进行配置(使用“/project/build/resources”(在 XPath 术语中)元素),并使用您的 <targetPath>可以复制到任何位置。 2.添加到config目录(src/main/liberty/config) 除了src/main/liberty/config/server.xml处的主服务器XML配置文件之外,您还可以将其他文件和目录放在那里,所有文件和目录都将通过开发模式复制过来。 所以你可以创建,例如src/main/liberty/config/mylib/my.jar,它会被复制到target/liberty/wlp/usr/servers/defaultServer/mylib/my.jar。然后,您可以从 server.xml 将此位置引用为相对于服务器配置目录的 "mylib/my.jar"。 (这不太适合要求复制到“.../shared/lib/global”的原始用例,但可能适合其他查看此问题的人)。 3.添加系统范围的依赖项 这在原来的问题中已经提到过。我不太喜欢这个解决方案。为了完整起见,我会提及它,但请您自行查找详细信息。 这可能会很有趣。


在 .NET 6 中使用 xsltc.exe 生成的程序集(XSLT 样式表)

我有一个 XSLT 样式表“Stylesheet.xsl”,我已使用 xsltc.exe 将其编译为“Stylesheet.dll” 该 DLL 包含在我的 .NET 6 中(net6.0 我有一个 XSLT 样式表“Stylesheet.xsl”,我已使用 xsltc.exe 将其编译为“Stylesheet.dll” 该 DLL 包含在我的 .NET 6 (<TargetFramework>net6.0</TargetFramework>) 项目中,用法如下: var xslCompiledTransform = new XslCompiledTransform(); xslCompiledTransform.Load(typeof(Stylesheet)); // ↑ System.IO.FileNotFoundException: Could not load file or assembly 'System.Data.SqlXml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified. xslCompiledTransform.Transform(@"..\..\..\input.xml", @"..\..\..\output.xml"); Load方法抛出FileNotFoundException,并显示消息“无法加载文件或程序集‘System.Data.SqlXml,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089’。系统找不到指定的文件。 ” 关于 xsltc.exe 的文档说明了以下内容: 脚本块仅在 .NET Framework 中受支持。 .NET Core 或 .NET 5 或更高版本不支持它们。 这严重暗示使用 xsltc.exe 编译的样式表应该在 .NET Core 或 .NET 5 或更高版本上工作(当不使用脚本块时),但在我的测试中却不起作用。 有谁知道为什么使用 xsltc.exe 编译的样式表不适用于 .NET 6 以及如何解决此问题? 更多详情 我在下面添加了有关我尝试过的更多详细信息。 请注意,我使用的样式表Stylesheet.xsl非常基本,没有使用特殊功能:<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes"/> <xsl:template match="/"> <output> <xsl:for-each select="input/book"> <booktitle> <xsl:value-of select="@title" /> </booktitle> </xsl:for-each> </output> </xsl:template> </xsl:stylesheet> 生成DLL的命令: "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\xsltc.exe" Stylesheet.xsl 在 SDK 样式的 .csproj 文件中引用 DLL: <ItemGroup> <Reference Include="Stylesheet"> <HintPath>.\Stylesheet.dll</HintPath> </Reference> </ItemGroup> input.xml:<input> <book title="First Title" /> <book title="Second Title" /> </input> output.xml 使用未编译的样式表执行转换时:<output> <booktitle>First Title</booktitle> <booktitle>Second Title</booktitle> </output> 我已经研究并发现其他人也有同样的问题,但还没有找到解决方案或解释为什么 Microsoft 文档隐式声明它应该可以工作,而在我的测试中却不起作用。 https://github.com/dotnet/runtime/issues/68129 在.NET Core 2.2中使用xsltc.exe生成的程序集? XslCompiledTransform.Load(type):无法加载文件或程序集“System.Data.SqlXml” System.IO.FileNotFoundException的堆栈跟踪: at System.Delegate.BindToMethodInfo(Object target, IRuntimeMethodInfo method, RuntimeType methodType, DelegateBindingFlags flags) at System.Reflection.RuntimeMethodInfo.CreateDelegateInternal(Type delegateType, Object firstArgument, DelegateBindingFlags bindingFlags) at System.Reflection.RuntimeMethodInfo.CreateDelegate(Type delegateType) at System.Xml.Xsl.XslCompiledTransform.Load(MethodInfo executeMethod, Byte[] queryData, Type[] earlyBoundTypes) at System.Xml.Xsl.XslCompiledTransform.Load(Type compiledStylesheet) at TestXslDotnet6.Program.Main(String[] args) in C:\Users\UserNameRedacted\Path\To\Repo\TestXslDotnet6\TestXslDotnet6\Program.cs:line 10 根据 GitHub 问题 .NET 6 不支持 XslCompiledTransform.Load(type(myXsltCompiled_dll)) 中的信息,看起来好像不支持,也不会支持。 2022年4月18日的评论说: 程序集 System.Data.SqlXml 包含命名空间 System.Xml.Xsl.Runtime,该命名空间在 .NET Core 中不存在。 根据移植指南,msxsl:script 在 .NET Core 上不可用。 .NET Framework 特定教程预计不起作用。 第二个人评论: 看起来 System.Data.SqlXml 是 SQLXML 的一部分,属于 据我所知,SQL Server org 不支持 .NET Core。 第三个人回复: 目前没有关于 SQLXML 和对 .NET 5+ 支持的计划, 我们还没有听到很多这方面的请求。我会 建议在此处开放用户声音以获得一些吸引力并 关于该主题的共识:https://aka.ms/sqlfeedback 所以,这就是您的答案:“msxsl:script 在 .NET Core 上不可用。.NET Framework 特定教程预计不起作用。”原因是非 .NET 组织必须使其成为可能,但没有计划这样做。他们没有意识到需求。 而且,他们承认该文档具有误导性。似乎在 2022 年 5 月对文档进行了更改,并创建了拉取请求:请注意,XSLT 脚本块仅限 .NET Framework。 我认识到这并没有为您提供解决方案或前进的道路,这令人失望。但这就是您问题的答案:.NET 6.0 根本不支持以这种方式进行转换。 虽然距离这个问题大约有两年了,但我还是想分享一下我为自己的目的所做的解决方法,因为我没有找到任何其他解决方案,可以帮助在基于 .NET Core 的转换中使用编译的 xslt dll。 因此,如果您想将 XslCompiledTransform 类与通过 xlstc.exe 生成的 dll 类型一起使用,请按照以下步骤操作: 生成dll类 xsltc.exe /class:Transform /out:Your.Assembly.dll 将 dll 反汇编为 ILL 代码 ildasm Your.Assembly.dll /out=Your.Assembly.ill 将 Your.Assembly.ill 中所有出现的 [System.Data.SqlXml] 替换为 [System.Private.Xml] 将你的IL编译回dll ilasm Your.Assembly.ill /dll 现在您可以将 Your.Assembly.dll 引用添加到您的 .NET Core 项目


“限制将街景标记添加到传单地图中的特定区域

我决定通过创建挪威夏季的公路旅行地图来开始学习 Leaflet 和 JavaScript,这是我的项目的可重复示例: 我决定通过创建挪威夏季的公路旅行地图来开始学习 Leaflet 和 JavaScript,这是我的项目的可重复示例: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css" /> <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/slick/slick.css"/> <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/slick/slick-theme.css"/> <script src="https://unpkg.com/leaflet/dist/leaflet.js"></script> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected]/slick/slick.min.js"></script> <link rel="stylesheet" href="https://unpkg.com/leaflet-routing-machine/dist/leaflet-routing-machine.css" /> <script src="https://unpkg.com/leaflet-routing-machine/dist/leaflet-routing-machine.js"></script> <style> body { margin: 0; } #map { width: 100%; height: 100vh; } .carousel { max-width: 300px; margin: 10px auto; } .carousel img { width: 100%; height: auto; } /* Custom styling for Geiranger popup content */ .geiranger-popup-content { max-width: 500px; padding: 20px; } </style> </head> <body> <div id="map"></div> <script> var map = L.map('map').setView([61.9241, 6.7527], 6); var streetViewMarker = null; // Variable to keep track of the Street View marker L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors' }).addTo(map); var roadTripCoordinates = [ [59.9139, 10.7522], // Oslo [62.2622, 10.7654], // Tynset [62.5949, 9.6926], // Oppdal [63.0071, 7.2058], // Atlantic Road [62.1040, 7.2054] // Geiranger ]; // Function to initialize Slick Carousel for a specific marker function initSlickCarousel(markerId, images) { $(`#${markerId}_carousel`).slick({ infinite: true, slidesToShow: 1, slidesToScroll: 1, dots: true, arrows: true }); // Add images to the carousel images.forEach(img => { $(`#${markerId}_carousel`).slick('slickAdd', `<div><img src="${img}" alt="Image"></div>`); }); } // Add markers for each destination with additional information and multiple pictures var destinations = [ { coordinates: [59.9139, 10.7522], name: 'Oslo', info: "../07/2023 : Start of the road-trip", images: ['https://www.ecologie.gouv.fr/sites/default/files/styles/standard/public/Oslo%2C%20Norvege_AdobeStock_221885853.jpeg?itok=13d8oQbU', 'https://via.placeholder.com/300', 'https://via.placeholder.com/300'] }, { coordinates: [62.2622, 10.7654], name: 'Tynset', info: "../07/2023 : Fly-fishing spot 1", images: ['https://www.czechnymph.com/data/web/gallery/fisheries/norway/glommahein/Kvennan_Fly_Fishing_20.jpg', 'https://via.placeholder.com/300', 'https://via.placeholder.com/300'] }, { coordinates: [62.5949, 9.6926], name: 'Oppdal', info: "../07/2023 : Awesome van spot for the night", images: ['https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSFRtpLlHWr8j6S2jNStnq6_Z9qBe0jWuFH8Q&usqp=CAU', 'https://via.placeholder.com/300', 'https://via.placeholder.com/300'] }, { coordinates: [63.0071, 7.2058], name: 'Atlantic Road', info: "../07/2023 : Fjord fishing", images: ['https://images.locationscout.net/2021/04/atlantic-ocean-road-norway.jpg?h=1100&q=83', 'https://via.placeholder.com/300', 'https://via.placeholder.com/300'] }, { coordinates: [62.1040, 7.2054], name: 'Geiranger', info: "../07/2023 : Hiking 1", images: ['https://www.fjordtours.com/media/10968/nicola_montaldo-instagram-26th-may-2021-0717-utc.jpeg?anchor=center&mode=crop&width=1120&height=1120&rnd=133209254300000000&slimmage=True', 'https://via.placeholder.com/300', 'https://via.placeholder.com/300'] } ]; // Use Leaflet Routing Machine with Mapbox Routing plugin to get and display the route L.Routing.control({ waypoints: roadTripCoordinates.map(coord => L.latLng(coord[0], coord[1])), router: L.Routing.mapbox('MAP_BOX_KEY'), draggableWaypoints: false, addWaypoints: false, lineOptions: { styles: [{ color: 'brown', opacity: 0.7, weight: 2 }] } }).addTo(map); // Remove the leaflet-routing-container from the DOM var routingContainer = document.querySelector('.leaflet-routing-container'); if (routingContainer) { routingContainer.parentNode.removeChild(routingContainer); } destinations.forEach(function (destination) { var marker = L.marker(destination.coordinates).addTo(map); var markerId = destination.name.replace(' ', '_'); marker.bindPopup(` <b>${destination.name}</b><br> ${destination.info}<br> <div class="carousel" id="${markerId}_carousel"></div> `).on('popupopen', function () { // Initialize Slick Carousel when the marker popup is opened initSlickCarousel(markerId, destination.images); }).openPopup(); }); // Add Street View panorama on map click map.on('click', function (e) { if (streetViewMarker) { // Remove the existing Street View marker map.removeLayer(streetViewMarker); } let lat = e.latlng.lat.toPrecision(8); let lon = e.latlng.lng.toPrecision(8); streetViewMarker = L.marker([lat, lon]).addTo(map) .bindPopup(`<a href="http://maps.google.com/maps?q=&layer=c&cbll=${lat},${lon}&cbp=11,0,0,0,0" target="blank"><b> Cliquer ici pour avoir un aperçu de la zone ! </b></a>`).openPopup(); }); </script> </body> </html> 一切都按预期进行,我不得不说我对渲染非常满意。然而,通过查看 Stackoverflow 上的不同主题,我发现可以通过单击地图来显示 Google 街景视图。这个功能真的很酷,但我想限制仅在我的公路旅行行程中添加街景标记的选项。 有人可以帮我吗? 您通过创建挪威夏季公路旅行地图开始了学习 Leaflet 和 JavaScript 的旅程,真是太棒了。到目前为止,您的项目设置看起来不错,我很乐意在您的进展过程中提供指导或帮助。 既然您已经包含了 Leaflet、Slick Carousel 和 Leaflet Routing Machine 库,看来您正计划使用 Slick Carousel 创建一个带有路线的交互式地图,也许还有一些附加功能。 以下是一些增强您的项目的建议: 地图初始化: 使用初始视图和要显示的任何特定标记或图层设置您的传单地图。 路由功能: 利用 Leaflet Routing Machine 将动态路线添加到您的地图。您可以自定义路线、添加航点并提供逐向指示。 照片轮播: 既然您提到了公路旅行地图,请考虑集成 Slick Carousel 来展示旅途中关键地点的照片或描述。这可以为您的地图添加视觉上吸引人的元素。 地图控制: 探索 Leaflet 插件或内置控件以增强用户体验。例如,您可以添加缩放控件或比例尺。 响应式设计: 确保您的地图能够响应不同的设备。 Leaflet 通常适合移动设备,但如果需要的话进行测试和调整是一个很好的做法。 数据层: 如果您有与您的公路旅行相关的特定数据点或事件,您可以使用标记或其他视觉元素在地图上表示它们。 JavaScript 交互性: 使用 JavaScript 为地图添加交互性。对于 ㅤ 实例,当用户单击标记时,您可以创建包含附加信息的弹出窗口。 记得迭代测试你的项目,并参考每个库的文档以获取详细的使用说明。 如果您有具体问题或在此过程中遇到挑战,请随时提问。祝您的公路旅行地图项目好运!


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