add-type 相关问题


为什么我的 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 之间的空格。


SQLServer 存在哪些会话提供程序类型?

如果您想在 web.config 中实现 SQL 会话,通常会有一些简单的内容,例如: 如果您想在 web.config 中实现 SQL 会话,通常会有一些简单的内容,例如: <sessionState mode="SQLServer" sqlConnectionString="myConnectionString"/> 但是,如果您想要一个自定义提供程序来执行诸如使用配置生成器隐藏连接字符串之类的操作,您可以编写以下内容: <sessionState mode="Custom" customProvider="SQLSessionProvider"> <providers> <add name="SQLSessionProvider" connectionStringName="SQLSessionService" type=""/> </providers> </sessionState> <connectionStrings configBuilders="CS_Environment"> <add name="SQLSessionService" connectionString="Environment_Key_Here" /> </connectionStrings> 问题是我不知道mode=SQLServer存在什么类型。在我的搜索中,我看到了 OBDC 会话的示例,其中 type=ObdcSessionStateStore 以及各种其他会话提供程序,但没有一个适用于 SQLServer。 SQLServer 存在哪些会话提供程序类型? 您可以使用此功能并通过 Nuget Package Manager 安装的 type 是 Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync 还应该安装SessionState.SessionStateModule。如果您是第一次将其安装到项目中,它将在您的 <sessionState> 中为您创建一个 web.config 模板。下面是如何使用它的示例: <connectionStrings configBuilders="CS_Environment"> <add name="SQLSession_Connection" providerName="System.Data.SqlClient" connectionString="SQLSessionProvider-configBuilder_failed" /> </connectionStrings> <sessionState cookieless="false" regenerateExpiredSessionId="true" mode="Custom" customProvider="SqlSessionStateProviderAsync"> <providers> <add name="SqlSessionStateProviderAsync" connectionStringName="SQLSession_Connection" type="Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync, Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> </providers> </sessionState> @8protons,您以前有使用过 Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync 的经验吗?我收到“在应用程序配置中找不到或连接字符串为空”错误 lmk 如果您能提供帮助


使用php以动态形式考虑用户输入

考虑我有一个像这样的简单表格: 考虑我有一个像这样的简单表格: <form method="post" action="index.php"> <input id='textsearch' type="text" placeholder="Enter a character" name="search"> <button onclick="addfields()">Add</button> </form> 此处,当用户单击“添加”按钮时,会触发 onclick 事件并激活 addfields() 功能。在该函数中,我设法在此表单中添加一个输入字段,表单现在如下所示: <form method="post" action="index.php"> <input id='textsearch' type="text" placeholder="Enter a character" name="search"> <input id='textsearch_1' type="text" placeholder="Enter a character" name="search_1"> <button onclick="addfields()">Add</button> </form> 但是,出现了一个问题。如果我使用 php 来访问这些变量,我可以使用这样的东西: <?php $first_char=$_POST["search"]; $second_char=$_POST["search_1"]; ?> 但是它到哪里结束呢?我事先不知道用户创建了多少字段并在这些字段中输入了数据。那么有什么办法可以解决呢? 注意:我知道许多用户不赞成使用 onclick() 功能。我仍然坚持这个不好的使用习惯。对此表示歉意。谢谢。 你可以尝试这个概念 HTML 表单 <form method="post" action="index.php"> <input id='textsearch' type="text" name="search[]"> <input id='textsearch_1' type="text" name="search[]"> <button onclick="addfields()">Add</button> </form> PHP <?php $search_text_array=$_POST["search"]; print_r($search_text_array); ?> 你应该得到这个 PHP 结果 Array ( [0] => textsearch [1] => textsearch_1 ) 在此示例中,javascript 使用onclick() 不相关,但解释如何获取 PHP 部分


如何解决数字格式异常?

index.html 输入第一个数字: 输入第二个数字... index.html <!DOCTYPE html> <html> <body> <form action="add"> Enter 1st number:<input type="text" name="num1"><br> Enter 2st number:<input type="text" name="num1"><br> <input type="submit"> </form> </body> </html> AddServlet.java 这是 servlet 代码。 package com.adithya; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class AddServlet extends HttpServlet { public void service(HttpServletRequest req,HttpServletResponse res) throws IOException { int i=Integer.parseInt(req.getParameter("num1")); int j=Integer.parseInt(req.getParameter("num2")); int k=i+j; PrintWriter out=res.getWriter(); out.println("result is"+k); } } 我正在尝试获取结果,但它显示了如下所示的异常。我无法理解例外情况。 ** 例外** 这显示了这样的异常。我无法识别问题所在。 java.lang.NumberFormatException: Cannot parse null string java.base/java.lang.Integer.parseInt(Integer.java:630) java.base/java.lang.Integer.parseInt(Integer.java:786) com.adithya.AddServlet.service(AddServlet.java:19) javax.servlet.http.HttpServlet.service(HttpServlet.java:623) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) 我不明白这是什么错误。我试图从 2 天开始解决这个问题。请任何人帮助我解决这个问题。但它不起作用。 您有 2 个相同的名字 num1,并且您正在尝试呼叫不在场的 num2。 Enter 2st number:<input type="text" name="num1"><br> 关于: Enter 2st number:<input type="text" name="num2"><br>


如何在java 8中获取findFirst()的索引?

我有以下代码: ArrayList 条目 = new ArrayList (); 条目.add(“0”); 条目.add(“1”); 条目.add(“2”); 条目.add(“3”); 字符串firstNotHiddenItem =


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

希望这不是一个愚蠢的问题,但我已经没有主意了...... 所以我有这个模式: 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 });


通过更少的 Java API 调用来映射 Google 云端硬盘内容的有效方法

大家好,我有一个代码,用于列出共享驱动器中存在的文件(以便稍后下载并创建相同的文件夹路径) 目前我做这样的事情: 哈希映射 大家好,我有一个代码,用于列出共享驱动器中存在的文件(以便稍后下载并创建相同的文件夹路径) 目前我正在做这样的事情: HashMap<String, Strin> foldersPathToID = new HashMap<>(); //searching all folders first saving their IDs searchAllFoldersRecursive(folderName.trim(), driveId, foldersPathToID); //then listing files in all folders HashMap<String, List<File>> pathFile = new HashMap<>(); for (Entry<String, String> pathFolder : foldersPathToID.entrySet()) { List<File> result = search(Type.FILE, pathFolder.getValue()); if (result.size() > 0) { String targetPathFolder = pathFolder.getKey().trim(); pathFile.putIfAbsent(targetPathFolder, new ArrayList<>()); for (File file : result) { pathFile.get(targetPathFolder).add(file); } } } 递归方法在哪里: private static void searchAllFoldersRecursive(String nameFold, String id, HashMap<String, String> map) throws IOException, RefreshTokenException { map.putIfAbsent(nameFold, id); List<File> result; result = search(Type.FOLDER, id); // dig deeper if (result.size() > 0) { for (File folder : result) { searchAllFoldersRecursive(nameFold + java.io.File.separator + normalizeName(folder.getName()), folder.getId(), map); } } } 搜索功能是: private static List<com.google.api.services.drive.model.File> search(Type type, String folderId) throws IOException, RefreshTokenException { String nextPageToken = "go"; List<File> driveFolders = new ArrayList<>(); com.google.api.services.drive.Drive.Files.List request = service.files() .list() .setQ("'" + folderId + "' in parents and mimeType" + (type == Type.FOLDER ? "=" : "!=") + "'application/vnd.google-apps.folder' and trashed = false") .setPageSize(100).setFields("nextPageToken, files(id, name)"); while (nextPageToken != null && nextPageToken.length() > 0) { try { FileList result = request.execute(); driveFolders.addAll(result.getFiles()); nextPageToken = result.getNextPageToken(); request.setPageToken(nextPageToken); return driveFolders; } catch (TokenResponseException tokenError) { if (tokenError.getDetails().getError().equalsIgnoreCase("invalid_grant")) { log.err("Token no more valid removing it Please retry"); java.io.File cred = new java.io.File("./tokens/StoredCredential"); if (cred.exists()) { cred.delete(); } throw new RefreshTokenException("Creds invalid will retry re allow for the token"); } log.err("Error while geting response with token for folder id : " + folderId, tokenError); nextPageToken = null; } catch (Exception e) { log.err("Error while reading folder id : " + folderId, e); nextPageToken = null; } } return new ArrayList<>(); } 我确信有一种方法可以通过很少的 api 调用(甚至可能是一个调用?)对每个文件(使用文件夹树路径)进行正确的映射,因为在我的版本中,我花了很多时间进行调用 service.files().list().setQ("'" + folderId+ "' in parents and mimeType" + (type == Type.FOLDER ? "=" : "!=") + "'application/vnd.google-apps.folder' and trashed = false").setPageSize(100).setFields("nextPageToken, files(id, name)"); 每个子文件夹至少一次......并且递归搜索所有内容需要很长时间。最后,映射比下载本身花费的时间更多...... 我搜索了文档,也在此处搜索,但没有找到任何内容来列出具有一个库的所有驱动器调用任何想法? 我想使用专用的 java API 来获取共享 GoogleDrive 中的所有文件及其相对路径,但调用次数尽可能少。 提前感谢您的时间和答复 我建议您使用高效的数据结构和逻辑来构建文件夹树并将文件映射到其路径,如下所示 private static void mapDriveContent(String driveId) throws IOException { // HashMap to store folder ID to path mapping HashMap<String, String> idToPath = new HashMap<>(); // HashMap to store files based on their paths HashMap<String, List<File>> pathToFile = new HashMap<>(); // Fetch all files and folders in the drive List<File> allFiles = fetchAllFiles(driveId); // Build folder path mapping and organize files for (File file : allFiles) { String parentId = (file.getParents() != null && !file.getParents().isEmpty()) ? file.getParents().get(0) : null; String path = buildPath(file, parentId, idToPath); if (file.getMimeType().equals("application/vnd.google-apps.folder")) { idToPath.put(file.getId(), path); } else { pathToFile.computeIfAbsent(path, k -> new ArrayList<>()).add(file); } } // Now, pathToFile contains the mapping of paths to files // Your logic to handle these files goes here } private static List<File> fetchAllFiles(String driveId) throws IOException { // Implement fetching all files and folders here // Make sure to handle pagination if necessary // ... } private static String buildPath(File file, String parentId, HashMap<String, String> idToPath) { // Build the file path based on its parent ID and the idToPath mapping // ... }


如何在node js中使用DOM更改文本内容

我想做的是 我想在输入错误密码时将标签更改为错误密码 但出现错误 ReferenceError:文档未定义 这是我的 HTML 文件 我想做的是 我想在输入错误密码时将 标签更改为错误密码 但出现错误 ReferenceError:文档未定义 这是我的 HTML 文件 <form action="/check" method="POST"> <label for="password">Password:</label> <input type="text" id="password" name="password" required> <input type="submit" value="Submit"> <p></p> </form> 这是我的 javascript 文件内容 import express from "express"; import {dirname} from "path"; import { fileURLToPath } from "url"; import bodyParser from "body-parser"; const __dirname = dirname(fileURLToPath(import.meta.url)); const app = express(); const port = 3000; const pass = "ILoveProgramming"; var enter = ""; app.use(bodyParser.urlencoded({extended:true})); function checker(req, res, next){ enter = req.body.password; console.log(enter); next(); } app.use(checker); app.get("/", (req,res) =>{ res.sendFile(__dirname +"/public/index.html"); }); app.post("/check",(req,res)=>{ if(pass === enter){ res.sendFile(__dirname+"/public/secret.html"); } else{ document.querySelector("p").textContent("The paswrd is wrong"); console.log("The password is incorrect"); } // console.log(enter); }); app.use(bodyParser); app.listen(port, () =>{ console.log(`server is live at ${port}`); }); 我对这一切都是新手所以把我当作一个没有任何经验的人 document对象是浏览器DOM API的一部分,它在服务器端不可用。在浏览器控制台上,它是 window 对象的属性。 window.document。 您正在尝试操作服务器上的 DOM,这是不可能的。您应该在浏览器接收并呈现 HTML 页面后在客户端处理 DOM 操作。为此,您应该在 HTML 文件内有一个 script 标签。 <script> // inside here you add your logic to access document <script/> script标签将在浏览器上执行,您可以访问此标签内的document对象


无法添加到存储库

当我使用 git add 时出现错误。 $ git add . 错误:索引 .editorconfig 时短读 错误:.editorconfig:无法插入数据库 错误:无法索引文件'.editorc...


如何在 cockroachdb/postgresql 中执行相当于 ADD CONSTRAINT IF NOT EXISTS 的操作?

大多数 PostgreSQL 语句支持 IF NOT EXISTS 子句以允许幂等迁移,例如CREATE TABLE IF NOT EXISTS foo .... 但 ALTER TABLE ... ADD CONSTRAINT 不存在。我怎样才能写...


Flatpickr AlpineJS 在危险范围选择上坚持插件

我有一个工作完美的 Flatpickr 日期范围日历,它将日期存储在会话存储中。这是我的代码: 我有一个工作完美的 Flatpickr 日期范围日历,它将日期存储在会话存储中。这是我的代码: <div x-data="{ chosenDates: sessionStorage.getItem('_x_range'), value: [], init() { let picker = flatpickr(this.$refs.picker, { mode: 'range', inline: false, dateFormat: 'm/d/Y', showMonths: 2, }) this.$watch('value', () => picker.setDate(this.value)) }, }" > <div class="flex items-center flex-1 gap-2 overflow-hidden border border-gray-500 rounded-lg"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="ml-4 bi bi-calendar-event-fill" viewBox="0 0 16 16"> <path d="M4 .5a.5.5 0 0 0-1 0V1H2a2 2 0 0 0-2 2v1h16V3a2 2 0 0 0-2-2h-1V.5a.5.5 0 0 0-1 0V1H4zM16 14V5H0v9a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2m-3.5-7h1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5"/> </svg> <input id="rangeValue" :value="chosenDates" placeholder="Add dates" x-ref="picker" type="text" class="p-0 py-4 placeholder-gray-600 border-0 bg-none focus:ring-0 " data-input> </div> </div> 设置项目: function dateRange() { var date = document.getElementById("rangeValue").value; sessionStorage.setItem("_x_range", date); sessionStorage.setItem("start", start); sessionStorage.setItem("end", end); const start = sessionStorage.getItem("start"); } $('#rangeValue').on('focus', ({ currentTarget }) => $(currentTarget).blur()) $("#rangeValue").prop('readonly', false) ``` Receive item: if (sessionStorage.getItem("_x_range") != null) { document.getElementById("chosenRange").innerHTML = sessionStorage.getItem("_x_range"); document.getElementById("rangeValue").value = sessionStorage.getItem("_x_range"); } ``` 如果可能的话,我想学习如何使用 AplineJS 和 Persist 来设置它,以免代码过多而过期。 这可能吗? 这是一个可能的解决方案: <div x-data="{ thePicker: null, chosenDates: $persist([]).using(sessionStorage).as('_x_range'), init() { this.thePicker = flatpickr(this.$refs.picker, { mode: 'range', inline: false, dateFormat: 'm/d/Y', showMonths: 2, defaultDate: this.chosenDates, onChange: (selectedDates) => {this.chosenDates = [...selectedDates];} }); }, }" > <div class="flex items-center flex-1 gap-2 overflow-hidden border border-gray-500 rounded-lg"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="ml-4 bi bi-calendar-event-fill" viewBox="0 0 16 16"> <path d="M4 .5a.5.5 0 0 0-1 0V1H2a2 2 0 0 0-2 2v1h16V3a2 2 0 0 0-2-2h-1V.5a.5.5 0 0 0-1 0V1H4zM16 14V5H0v9a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2m-3.5-7h1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5"/> </svg> <input type="text" x-ref="picker" placeholder="Add dates" class="p-0 py-4 placeholder-gray-600 border-0 bg-none focus:ring-0" > <span title="Clear" class="text-blue-600 cursor-pointer" @click="thePicker.clear()" > X </span> </div> <div x-text="chosenDates"> </div> </div> 日期范围存储在 Alpine chosenDates 变量中,该变量通过 Persist 进行持久化并初始化为空数组。 当日期选择器初始化时,chosenDates变量用于填充defaultDate参数。 选择日期范围后,flatpicker 会触发 onChage 事件,因此我使用它将新范围复制到 chosenDates 变量中。 我添加了一个 “clear” 按钮以 flatpicker 方式重置输入字段,调用 clear() 方法(这是一个简单的示例),然后我必须将 flatpicker 引用存储在 thePicker 中变量. 我还添加了一个 通过 x-text 显示 choosenDates 的内容


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

我决定通过创建挪威夏季的公路旅行地图来开始学习 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 为地图添加交互性。对于 ㅤ 实例,当用户单击标记时,您可以创建包含附加信息的弹出窗口。 记得迭代测试你的项目,并参考每个库的文档以获取详细的使用说明。 如果您有具体问题或在此过程中遇到挑战,请随时提问。祝您的公路旅行地图项目好运!


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


EFCore 迁移是否应该致力于版本控制?

运行 dotnet ef migrations add XYZ 将导致在项目中创建 Migrations 目录。该目录是否应该提交版本控制(Git 等)?


创建分区时,Athena Iceberg 目前不支持查询类型

我在 Athena 中运行以下 sql 来创建分区 ALTER TABLE 数据库.表 ADD 分区(分区一='123',分区二='456') 位置 's3:///data/


如何在闰年中向日期时间添加一年

我想从给定日期获取下一年月份的最后一天 这是我的做法: $copy = new \DateTime(); $lastDay = new \DateTime($copy->add((new \DateInterval('P1Y')))->format...


特定标签的selenium xpath

此输入标签的 Xpath 是什么 ” 此输入标签的 Xpath 是什么 "<input autocapitalize="sentences" autocorrect="off" class="css-1cwyjr8 r-19sur4y r-qklmqi r-1phboty r-1wdu9aa r-ubezar r-16dba41 r-10paoce r-12rqra3 r-13qz1uu" dir="auto" spellcheck="false" type="email" data-focusable="true" value="" style="font-family: inherit;"> 如果只有 @type=email 的元素,则可以使用 //input[@type='email']


gitlab 管道:在 gitlab-ci.yml 中获取主机名

我在 gitlab-ci.yml 中运行了几个 docker 命令。 其中一些需要将当前计算机 IP 地址传递给它们,如下所示: docker build --pull -t my_image 。 --add-host=:<


Angular 12:Firebase 模块未正确提供(?)

第一次使用Firebase,所以我不知道发生了什么。我没有修改使用 ng add @angular/fire 获得的配置,所以我的 AppModule 中的内容是: @NgModule({ 声明:[


Flutter 中的状态错误

如何修复此错误:StateError(错误状态:在没有注册事件处理程序的情况下调用 add(SignUp Button Pressed)。请确保通过 on((event, eager) {...}) 注册处理程序) 注册区: 重要...


Doctrine ORM:正则表达式与表达式生成器中的 DQL 函数匹配

我在 Doctrine ORM 中注册了 REGEX() DQL 函数。 现在,我想在表达式生成器中使用该函数 $expr = $queryBuilder->expr(); $or = $expr->orX(); $or->add($expr->eq(&q...


如何使用 2 个条件角度选择器

我有一个带有选择器的多输入组件,如下所示: 我有一个带有选择器的多输入组件,如下所示: <app-input type="currency" formControlName="currency"></app-input> <app-input type="date" formControlName="dateOfBirth"></app-input> 因此,从该组件中,我有一个像这样的选择器: @Component({ selector: 'app-input[type=currency]', }) @Component({ selector: 'app-input[type=date]', }) 现在,我想添加多个 currency 组件。一种用于默认货币成分,第二种用于具有动态货币符号的货币。 所以,我想通过选项让它变得不同。当选择器有选项时,显示带动态符号的货币,否则或默认,显示不带符号的默认货币。 我一直在尝试使用下面的这个选择器,但它不起作用。 对于默认货币: @Component({ selector: 'app-input:not([options])[type=currency]', }) 对于动态符号货币: @Component({ selector: 'app-input[options][type=currency]', }) 提前谢谢您 您可以像这样添加数据属性来区分选择器 无符号: @Component({ selector: 'app-input[type=currency]', }) 带有符号: @Component({ selector: 'app-input[type=currency][data-symbols]', }) html with symbols: <app-input type="currency" formControlName="currency" data-symbols></app-input> without symbols: <app-input type="currency" formControlName="currency"></app-input>


显示输入类型日期的占位符文本

占位符不适用于直接输入类型日期和日期时间本地。 占位符不适用于直接输入类型 date 和 datetime-local。 <input type="date" placeholder="Date" /> <input type="datetime-local" placeholder="Date" /> 该字段在桌面上显示 mm/dd/yyy,而在移动设备上则不显示任何内容。 如何显示 Date 占位符文本? 使用onfocus="(this.type='date')",例如: <input required="" type="text" class="form-control" placeholder="Date" onfocus="(this.type='date')"/> 使用onfocus和onblur...这是一个例子: <input type="text" placeholder="Birth Date" onfocus="(this.type='date')" onblur="if(this.value==''){this.type='text'}"> 在这里,我尝试了 data 元素中的 input 属性。并使用 CSS 应用所需的占位符 <input type="date" name="dob" data-placeholder="Date of birth" required aria-required="true" /> input[type="date"]::before { content: attr(data-placeholder); width: 100%; } /* hide our custom/fake placeholder text when in focus to show the default * 'mm/dd/yyyy' value and when valid to show the users' date of birth value. */ input[type="date"]:focus::before, input[type="date"]:valid::before { display: none } <input type="date" name="dob" data-placeholder="Date of birth" required aria-required="true" /> 希望这有帮助 <input type="text" placeholder="*To Date" onfocus="(this.type='date')" onblur="(this.type='text')" > 这段代码对我有用。只需使用这个即可 对于 Angular 2,你可以使用这个指令 import {Directive, ElementRef, HostListener} from '@angular/core'; @Directive({ selector: '[appDateClick]' }) export class DateClickDirective { @HostListener('focus') onMouseFocus() { this.el.nativeElement.type = 'date'; setTimeout(()=>{this.el.nativeElement.click()},2); } @HostListener('blur') onMouseBlur() { if(this.el.nativeElement.value == ""){ this.el.nativeElement.type = 'text'; } } constructor(private el:ElementRef) { } } 并像下面一样使用它。 <input appDateClick name="targetDate" placeholder="buton name" type="text"> 对于 React,你可以这样做。 const onDateFocus = (e) => (e.target.type = "datetime-local"); const onDateBlur = (e) => (e.target.type = "text"); . . . <input onFocus={onDateFocus} onBlur={onDateBlur} type="text" placeholder="Event Date" /> 我是这样做的: var dateInputs = document.querySelectorAll('input[type="date"]'); dateInputs.forEach(function(input) { input.addEventListener('change', function() { input.classList.add('no-placeholder') }); }); input[type="date"] { position: relative; } input[type="date"]:not(.has-value):before { position: absolute; left: 10px; top: 30%; color: gray; background: var(--primary-light); content: attr(placeholder); } .no-placeholder:before{ content:''!important; } <input type="date" name="my-date" id="my-date" placeholder="My Date"> 现代浏览器使用 Shadow DOM 来方便输入日期和日期时间。因此,除非浏览器出于某种原因选择回退到 text 输入,否则不会显示占位符文本。您可以使用以下逻辑来适应这两种情况: ::-webkit-calendar-picker-indicator { @apply hidden; /* hide native picker icon */ } input[type^='date']:not(:placeholder-shown) { @apply before:content-[attr(placeholder)]; @apply sm:after:content-[attr(placeholder)] sm:before:hidden; } input[type^='date']::after, input[type^='date']::before { @apply text-gray-500; } 我使用了 Tailwind CSS 语法,因为它很容易理解。让我们一点一点地分解它: ::-webkit-calendar-picker-indicator { @apply hidden; /* hide native picker icon */ } 使用其 Shadow DOM 伪元素选择器隐藏本机选择器图标(通常是日历)。 input[type^='date']:not(:placeholder-shown) { @apply before:content-[attr(placeholder)]; @apply sm:after:content-[attr(placeholder)] sm:before:hidden; } 选择所有未显示占位符的 date 和 datetime-local 输入,并且: 默认使用 placeholder 伪元素显示输入 ::before 文本 在小屏幕及以上屏幕上切换为使用 ::after 伪元素 input[type^='date']::after, input[type^='date']::before { @apply text-gray-500; } 设置 ::before 和 ::after 伪元素的样式。


使用 signalStore 和 rxMethod 创建实体

我有一条我理解的错误消息,但我不知道如何解决它。 “add”调用无需 HTTP 和“rxMethod”即可工作。但是,无法在构造函数之外加载此方法。什...


如何将具有自定义标准化功能的 Keras TextVectorization 层配置保存到 pickle 文件中并重新加载?

我有一个 Keras TextVectorization 层,它使用自定义标准化函数。 def custom_standardization(input_string,保留= ['[',']'],add = ['¿']): strip_chars = 字符串.标点符号 ...


在闪存驱动器中写入文件(仅限Android)

是否可以使用flutter将文件保存到闪存驱动器? 我正在使用带有 USB c 端口的随身碟,如下所示: https://www.bestbuy.com/site/sandisk-ultra-dual-drive-go-1tb-usb-type-a-usb-type-c-flash-


Laravel 8 验证数组

我有一个 Laravel 8 表单,其中包含一系列用户联系方式。 我有一个 Laravel 8 表单,其中包含一系列用户联系方式。 <div> <input name="contactdetails[{{ $key }}][email]" type="text"> <input name=" contactdetails [{{ $key }}][mobile]" type="text"> </div <div> <input name=" contactdetails [{{ $key }}][email]" type="text"> <input name=" contactdetails [{{ $key }}][mobile]" type="text"> </div <div> <input name=" contactdetails [{{ $key }}][email]" type="text"> <input name=" contactdetails [{{ $key }}][mobile]" type="text"> </div 我的验证规则如下所示: contactdetails.*.email=> ‘email:rfc,dns’, contactdetails.*. mobile => required_with:email|numeric', 我需要验证是否至少输入了一封电子邮件(但不是全部)以及相应的手机。 你必须这样做: 'contactdetails' => 'array|min:1', 'contactdetails.*.email' => 'email:rfc,dns', 'contactdetails.*.mobile' => 'required_with:contactdetails.*.email|numeric|nullable', 这意味着 contactdetails 必须是数组并且至少有一个成员 并更好地添加正则表达式移动角色来验证正确的手机号码


Pydantic.BaseModel.model_dump() 通过 AttributeError

我正在尝试使用 Pydantic.BaseModel.model_dump() 但当我调用它时 AttributeError: type object 'BaseModel' has no attribute 'model_dump' 引发。还尝试实例化 BaseModel 类。


替换字符串后在 echo 中运行额外的 php 代码

我想在替换表单中的一些字符串后执行附加的php代码 这是我在 form.php 上的表单代码 我想在替换表单中的一些字符串后执行附加的php代码 这里是我在 form.php 上的表单代码 <form method="post" action="result.php"> <input type="text" name="yourtext"> <input type="submit"> </form> 例如文本是 my name is bagu and i live under a rock thanks 这里是 result.php 代码 <?php $mytext = $_POST['yourtext']; $find = ["my name is","and i live", "thanks"]; $replace = ["<?php open_form('Form/insert') ?><input name='name' type='text' value='","'><br><input name='address' type='text' value='","'><input type='submit'><?php form_close() ?>"]; $intoform = str_replace($find, $replace, $mytext); echo $intoform; ?> 我想要的结果是“bagu”和“under a rock”分别在一个正在工作的文本框中 但问题是 echo 中的 php 代码不起作用(我认为???因为它是) 是的,这是 codeigniter 的表格 谢谢 ====== 编辑:我尝试了没有 echo 和变量的 result.php ,也就是我在 form.php 中提交文本后想要的结果 <?php open_form('Form/insert') ?> <input name='name' type='text' value='bagu'><br> <input name='address' type='text' value='under a rock'> <input type='submit'> <?php form_close() ?> 并且如果“ 使用 preg_match 提取姓名和地址。 die 子句仅用于指示输入字符串格式错误,可以根据需要替换为更友好的提示。 preg_match('/my name is (.+) and i live (.+) thanks/', $mytext, $m) or die('Input text is invalid'); 如果preg_match成功,$m[1]将包含名称,$m[2]将包含地址,然后您可以将值插入表单 <?php open_form('Form/insert') ?> <input name='name' type='text' value='<?=$m[1]?>'><br> <input name='address' type='text' value='<?=$m[2]?>'> <input type='submit'> <?php form_close() ?> 需要补充的是,在实际操作中,应检查用户输入的姓名和地址的合法性。例如,要限制它们仅包含字母和空格,第一步中的正则表达式 (.+) 可以更改为 ([A-Za-z ]+)。


为什么gcc将8字节格式的char类型传递给函数汇编

为了学习汇编,我正在查看 GCC 使用 -S 命令为一些简单的 c 程序生成的汇编。我有一个 add 函数,它接受一些整数和一些字符并将它们添加在一起。 ...


如何在<script id="template" type="text/ractive">中语法高亮HTML?

是否有任何 Vs Code 扩展可以在内部语法高亮 HTML? <p>你好,世界!</p>


在使用 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;


如何显示摘要结果?

如何导出汇总结果,我无法使用stargazer。 stargazer(摘要(my_plm_pooling_1, vcov = 函数(x) vcovHC(x)), type='text') 结果: 暗名错误 (x) <- dn : comprimento de 'dim...


使用 qr-image 生成 Wi-Fi QRCode

npm 模块 qr-image 允许使用 NodeJS 生成 QRCode,如下所示: 从“qr-image”导入 qr; 从 'fs' 导入 fs; qr.image('https://google.com/search?q=hello%20world!', {type:'...


在`dplyr/across`中,如何排除给定的列

在 dplyr/across 中,我想 *-1 到数字列排除 a1 或 excelue a1 a2 图书馆(tidyverse) 原始数据<- data.frame( type=c('A','B','C'), cat=c("cat1","cat2","


如何在PyGame中使用精灵?

我想画3行矩形。为此,我想使用 pygame.sprite。团体()。我收到错误消息: TypeError: 'type' object is not subscriptable.我在此处检查了错误消息。


Kibana 无法从 Elasticsearch 节点检索版本信息。 getaddrinfo EAI_AGAIN elasticsearch

我正在尝试通过 docker-compose.yml 文件安装 kibana 和 elasticsearch,我得到了 {"type":"log","@timestamp":"2024-01-09T18:24:14+00:00 “,”标签...


如何从typing.TypeAlias迁移到type statements

我创建了一个类型别名,用于通过类型注释定义数据类中的成员变量: >>> 从输入导入 TypeAlias >>> 数字:TypeAlias = int |漂浮 >>>...


如何使用DomDocument通过id获取值?

我正在尝试使用 DomDocument 获取下面表单的值,但到目前为止仍然失败 我正在尝试使用 DomDocument 获取下面表单的值,但到目前为止仍然失败 <?php $string ='<form action="profile" method="post" enctype="multipart/form-data"> <input type="hidden" name="id_user" id="id_user" value="123"> <input type="hidden" name="logo" id="logo" value="path/to/logo1.png"> <input type="hidden" name="status" id="status" value="Ok"> <input type="submit" value="PROFILE"> </form>'; ?> 这种情况下如何正确使用DomDocument? 我正在尝试下面的代码 $dom = new DomDocument(); $dom->loadHTML($string); $dom->getElementById("id_user"); 我期望得到 123 作为返回值 DomDocument 有点麻烦,但如果您遵循文档,您就可以到达那里。我找到了这条路线: $dom->getElementById("id_user")->attributes->getNamedItem("value")->value 返回: 123 参见:https://onlinephp.io/c/c37dc 可能还有其他方法可以做到同样的事情。


如何使用 virt-install 在 aarch64 虚拟机上配置显示

我正在运行这个命令: virt-install --virt-type kvm --name oracle --ram 4096 --location=/ssd/OracleLinux-R9-U3-aarch64-dvd.iso --磁盘路径=/ssd/OracleLinux-R9-U3-aarch64 -cloud.qcow2 --network=de...


如何在Typescript中组合多个属性装饰器?

我有一个带有属性 _id 的类模板,它具有来自 class-transformer 和 typed-graphql 的装饰器 从 'class-transformer' 导入 {classToPlain, Exclude, Expose, plainToClass, Type }; 重要...


数组工厂 Laravel 上的随机选择值

我进行了用户迁移: $table->enum('type',['卖家','买家'])->default('卖家'); 我想在使用 ModelFactory 时如何获得随机值卖家或买家? $factory->define(App\User::class,


Python 中带有参数的类装饰器,引发 TypeError:缺少 1 个必需的位置参数:'type'

以下代码: def myDecorator(cls, 类型): 类包装器(cls): contaVarClasse = 0 def __init__(cls, *args, **kwargs): 以 cls 为单位的值。


如果类型是从变量进行数据绑定,则通过 <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; } }


使用排除映射类型时无法删除可选

我想删除以下类型字段的可选字段: 类型可选 = { a?:字符串; b?:数字; } type Mapped1 = { [K in keyof Optinal]-?: Optinal[K] } /* 类型映射1 = { a:字符串; 乙:


我可以让 argparse 在两个选项名称之后不重复参数指示吗?

当我为 argparse 指定一个具有短名称和长名称的参数时,例如: parser.add_argument("-m", "--min", dest="min_value", type=float, help="最小值...


如何使用 Nuxt 中间件正确检查 Firebase Auth?

我有一个与 Firebase 连接的 Nuxt 应用程序。我有一个可组合的 useAuth() ,代码如下: 从 'firebase/auth' 导入 { type User, onAuthChangedListener }; 导出默认函数 () { c...


React-Redux useSelector typescript type for state

我正在使用 React-Redux 中的 useSelector(state => state.SLICE_NAME) 挂钩,但是我在定义状态参数时遇到了困难。它默认设置为未知,因此当我尝试时会收到错误...


mongoose 中的 finOne() 失败并显示 MongoServerError: Expected field collationto be of type object

我正在尝试使用express和MongoDb实现简单的注册验证,但下面的代码行总是失败并出现以下错误 const emailExist = wait User.findOne({email: req.body.


如何删除颜色输入的边框?

我使用 JavaScript 生成的 HTML5 颜色选择器元素来让用户设置另一个元素的颜色。当浏览器执行 input type="color" 时,它会绘制一个显示


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