intl-tel-input 相关问题


MazPhoneNumberInput Vue.js 上的自动对焦

我在表单中使用 MazPhoneNumberInput 组件(https://maz-ui.com/components/maz-phone-number-input): 我正在以这种方式使用 MazPhoneNumberInput 组件(https://maz-ui.com/components/maz-phone-number-input): <MazPhoneNumberInput v-model="phoneNumber" v-model:country-code="countryCode" show-code-on-list :preferred-countries="['DE', 'US', 'GB']" noFlags /> 并且想在手机输入上设置自动对焦。 MazPhoneNumberInput 组件本身没有 autofocus 属性,但它基于具有 autofocus 属性的 MazInput 组件(https://maz-ui.com/components/maz-input): 我尝试通过 javascript 使用 onMounted 方法设置焦点: import AppLayout from "@/Layouts/Auth/AppLayout.vue"; import MazPhoneNumberInput from 'maz-ui/components/MazPhoneNumberInput' import {ref, onMounted} from 'vue' const phoneNumber = ref() const countryCode = ref('DE') const focusInput = () => { phoneNumber.value.focus(); }; onMounted(focusInput); 但是没有成功。 如何在手机输入上设置自动对焦? 这可以使用 template ref 来完成,它可以访问组件的 DOM 元素。由于根元素只是多个其他元素的包装,因此需要额外的查询来获取实际的电话输入,然后您可以将其聚焦: onMounted(async () => { const phoneEl = phone.value.$el // MazPhoneNumberInput root DOM element const phoneInput = phoneEl.querySelector('input[type=tel]') // inner input DOM element await nextTick() // can focus after next DOM update phoneInput.focus() })


Intl.supportedValuesOf 类型“typeof Intl”上不存在属性“supportedValuesOf”

我正在使用 dayJS 作为我的日期时间库,并且想要呈现所有时区的列表。 我尝试使用 Intl 对象: Intl.supportedValuesOf("时区") 但我收到了打字稿 e...


是否可以更改 UIApplication.shared.open("tel://XXXXXX") 确认对话框的颜色方案?

应用程序使用深色和浅色模式。应用程序主题可能与系统主题不同。 但是当我调用 UIApplication.shared.open("tel://XXXXXX") 时,会显示系统确认对话框


使用自定义React)组件(在Echarts工具提示中带有钩子

我目前正在使用echarts实现散点图。我想使用一个 i18n 函数,它使用 intl lib 中的 formatNumber 。 问题是我不知道是否需要写...


如何使用 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>


使用 React 和 Enzyme 测试设置文本值

如何设置文本输入的文本,然后使用 React / Enzyme 测试它的值? const input =wrapper.find('#my-input'); 输入.模拟('改变', { 目标:{ 值:'abc' } } ); 常量 va...


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

占位符不适用于直接输入类型日期和日期时间本地。 占位符不适用于直接输入类型 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 伪元素的样式。


我无法打印onChange的值

从“react”导入React; 从“react-input-mask”导入InputMask; 从“./inputMask.module.scss”导入样式; 从“反应...


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 必须是数组并且至少有一个成员 并更好地添加正则表达式移动角色来验证正确的手机号码


替换字符串后在 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 ]+)。


html input onchange 不接受匿名函数

为什么这不起作用? chrome 给我一个错误, 未捕获的语法错误:意外的 tok...


闪亮的server.R无法读取全局变量

./app 中的两个文件 ui.R 图书馆(闪亮) 一个<- 1 ui <- fluidPage( textOutput("test") ) server.R server <- function(input, output) { output$test <- renderText({ a ...


特定标签的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']


应用于 html 表单时 file_get_contents('php://input') 中的内容

我有一个关于 file_get_contents('php://input') 的一般性问题。当此代码应用于提交处理的 时,实际返回什么? 这是关于一些... 我有一个关于 file_get_contents('php://input') 的一般性问题。当此代码应用于提交处理的 <form> 时,实际返回什么? 这是关于我试图遵循和理解的一些代码。代码没有问题,可以正常运行。我只是好奇。 Javascipt 处理表单按钮上的单击功能。然后 JavaScript 代码调用 payment_ini.php 脚本,其中包含 file_get_contents('php://input'): // Retrieve JSON from POST body $jsonStr = file_get_contents('php://input'); $jsonObj = json_decode($jsonStr); $jsonObj是否包含正在处理的表单中的名称/值?如果表单中有 name、email、phone 字段,它们会在 $jsonObj 中吗? 我尝试在开发模式下添加一些日志记录/打印输出代码,但它要么会导致错误,要么不会显示。 感谢您帮助我看清蜘蛛网。 哦! error_log("jsonStr: " . $jsonStr); 添加到我的 error_log。它显示了 file_get_contents('php://input') 中的内容 之前,我尝试过error_log("jsonObj: " . $jsonObj);,但不喜欢该对象。 感谢您的浏览


流程图 - Python

我需要为给定的流程图编写一个程序 我的代码: x,y,d=列表(map(int,input().split())) 温度=0 而 x<=y: x=temp while temp>0: 如果温度%10==d: ...


如何解决数字格式异常?

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>


<input>字体大小不断改变宽度

所以基本上我有这个 #计算器 { 背景颜色:#212121; 边框半径:10px; 溢出:隐藏; 显示:内联块; } #功能{ 宽度:100%; 高度:100%; 玛格...


如何使用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 可能还有其他方法可以做到同样的事情。


会话数据未跨请求保留 - Laravel/Inertia

我正在尝试在发布请求的会话中保存数据,然后重定向到另一个页面 尝试 { $tenant = 租户::where('email', '=', $request->input('email'))->firstOrFail(); } 抓住(


fasttext 可以在字符级别进行分类吗?

我正在使用 fasttext 模型来预测文本标签。 通常 fasttext 可以在单词级别对文本进行分类,例如: 模型 = fasttext.train_supervised(input="training_fasttextFormat.csv", lr=0...


在完全相同的行上插入2个不同的sql插入语句

def placeOrder_2(): buy_amount = int(input("请输入您想要购买的不同产品的数量:")) 对于范围内的 x(购买金额): p_id = 输入(“E...


是否可以让 input() 函数不等待你输入内容?

我正在尝试使用文本制作屏幕。例如: ......游戏的事情...... ……………… 按回车键即可播放。 ……………… 版本 1.3………… 我想做它,这样它就会...


SyntaxError:用于中断 true while 并打印 cod 的语法无效

我想在打破 True while 后打印“再见”,但我遇到了麻烦。 这是我的代码 在此输入图像描述 而(真): number = (input("请输入数字...


角度属性绑定到新对象实例

在 Angular (15) 中,如果我们有一个组件属性 (@Input),它是一个对象 - 例如 [config]="{ size: 10, label: 'hello' }" - 就是被实例化的对象在 HTML 中重新创建...


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

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


无法将<label>和<input>放在同一行

我似乎无法在“计划首选项”下将 和 放在同一行。代码笔在这里。 我尝试过浮动和表格单元格属性操作。任何帮助都会


TrustPilot Id 在硬重新加载时不显示

我有这个角度组件,似乎使 TrustPilot 小部件在硬刷新后消失,任何人都可以解释为什么吗? 从 '@angular/core' 导入 { Component, Input, OnInit }; 宣告全球...


如何配置验证以对无效输入使用“is-invalid”类

默认情况下,ASP.NET Core 中的输入验证使用类 input-validation-error,但 Bootstrap 5 使用 is-invalid。 我找到了一些解决方案: 创建样式 使用 jQuery.validate.unobtrusi...


玩笑更新后无法读取未定义的属性“html”

对于使用 jest 的 Angular v12 项目,我刚刚将 jest 更新到版本 28。但是现在,我收到以下错误 失败 src/app/components/update-input/update-input.directive.spec.ts ● 测试套件


Pylance 无法识别内置的 python 函数

我的猫跑过我的键盘,现在 Pylance 无法识别 print、hex、len 和 input 等内置函数,并且它标记为未定义。同样在我的 Django 项目中,一些类的导入开始了......


我想了解Python中这段代码的逻辑

我的老师给了我这个问题:制作一个读取整数并打印它的程序。 所以我找到了这段代码: integer_number = int(input("请输入一个整数:")) print("您输入了:&quo...


我是编码新手,在Python中我想知道是否可以让input()函数不等到你输入内容

我正在尝试使用文本制作屏幕。 例如: ......游戏的事情...... ……………… 按回车键即可播放。 ……………… 版本 1.3………… 我想做它,这样它就会...


使用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 部分


为什么我的Python函数不返回任何内容(第一次它会返回true,但递归函数调用本身则不会返回任何内容)

def 登录(log = 1): con = input(f"{na} 你准备好玩游戏了吗是/否") if ((con == "是")or(con == "是")or(con == "y")or(con == "Y&qu...


如何使用 Bootstrap 5 禁用自定义范围而不更改样式?

我有范围: 我有范围: <!DOCTYPE html> <html lang="en"> <head> <!-- Bootstrap --> <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous" /> </head> <body> <div class="container mb-4 col-sm-5"> <input type="range" class="custom-range" min="0" max="10" value="10" id="range-input" style="width: 100%"> </div> </body> </html> 我想禁用它(它应该仍然看起来一样,但用户不能再与它交互),但是不改变样式。例如: 图中,顶部的启用,底部的禁用;我想禁用它,同时保持顶级范围的样式。 我尝试手动重新创建原始样式,但没有成功: <!DOCTYPE html> <html lang="en"> <head> <!-- Bootstrap --> <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous" /> <style> input[type=range]:disabled { background-color: blue; color: blue; background: blue; } </style> </head> <body> <div class="container mb-4 col-sm-5"> <input type="range" class="custom-range" min="0" max="10" value="10" id="range-input" style="width: 100%" disabled> </div> </body> </html> 除此之外,我在研究中找不到任何其他可能的解决方案。 您实际上需要“如何”禁用它? 设置 pointer-events: none 并添加 tabindex="-1",你会得到一个看起来仍然相同的元素,但用户无法再与之交互(至少通过鼠标单击/点击,并且他们无法通过键盘将其聚焦)控制其中之一 - 不确定是否还有其他什么?) 由于没有设置 name 属性,该字段不会成为表单提交数据集的一部分 - 如果在您的实际用例中有所不同,您也可以删除(并重新设置)名称,当您可以打开和关闭 tabindex。


如何使用 Bootstrap 5 将嵌入水平居中

我正在尝试使用上面的图像进行集中输入。我按照位置文档进行操作,但不知何故图像没有水平集中: 代码: 我正在尝试使用上面的图像进行集中输入。我按照位置文档进行操作,但不知何故图像没有水平集中: 代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Title --> <title>Title</title> <!-- Css --> <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous"> </head> <body> <div class="container position-absolute top-50 start-50 translate-middle"> <embed class="logo" src="https://www.google.com.br/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" alt="Logo"> <form action="/streams" method="POST"> <div class="input-group"> <input class="form-control border-danger border-5" type="text" aria-describedby="start-button"> <button class="btn btn-danger" type="submit" id="start-button">Click</button> </div> </form> </div> </body> </html> 我尝试手动执行此操作并使用 display flex,但没有成功。 使用text-center链接 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Title --> <title>Title</title> <!-- Css --> <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous"> </head> <body> <div class="container text-center"> <embed class="logo " src="https://www.google.com.br/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" alt="Logo"> <form action="/streams" method="POST"> <div class="input-group"> <input class="form-control border-danger border-5" type="text" aria-describedby="start-button"> <button class="btn btn-danger" type="submit" id="start-button">Click</button> </div> </form> </div> </body> </html>


Laravel 购物车页面,表单内有一个表单,用于处理删除和提交数据更新数据库

我有一个购物车页面,表格内有一个表格,也许你可以建议我应该做什么? 根据图片,我给出的蓝色圆圈是一个表格 我的刀片代码 我有一个购物车页面,表格内有一个表格,也许你可以建议我应该做什么?根据图片我给出的蓝色圆圈是一个表格我的刀片代码<table class="table"> <thead> <tr> <th scope="col">No</th> <th scope="col">Nama Barang</th> <th scope="col">Quantity</th> <th scope="col">Action</th> </tr> </thead> <tbody> @php $no = 1; @endphp @forelse ($permintaans as $b) <tr> <td>{{ $no ++ }}</td> <td> {{ $b->nama_kategori }} {{ $b->nama_atk }} </td> <td> <form action="{{ route('permintaan.update', $b->id) }}" method="POST" style="display: inline-block;"> @csrf @method('PUT') <div class="input-group input-group-sm mb-3"> <input type="number" class="form-control" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-sm" name="satuan_permintaan" min="0" max={{ $b->stok }} required> <span class="input-group-text" id="inputGroup-sizing-sm">{{ $b->subsatuan_atk }}</span> </div> </td> <td> <form action="{{ route('permintaan.destroy', $b->id) }}" method="POST" style="display: inline-block;"> @csrf @method('DELETE') <button type="submit" class="btn custom2-btn"><svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="red" class="bi bi-trash" viewBox="0 0 16 16"> <path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5m2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5m3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0z"/> <path d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4zM2.5 3h11V2h-11z"/> </svg></button> </form> </td> </tr> @empty @endforelse </tbody> </table> 我的控制器public function store(Request $request) { $task = new Permintaan(); $task->atk_id = $request->input('atk_id'); $task->proses = 'Proses'; if (Permintaan::where('atk_id', $task->atk_id)->exists()){ return redirect('/atk/permintaan')->with(['info' => 'ATK Sudah Dalam Permintaan']); } else{ $task->save(); return redirect()->route('permintaan.index'); } } public function destroy($id) { $permintaan = Permintaan::find($id); $permintaan->delete(); return redirect()->route('permintaan.index'); } 我要处理删除并提交数据更新数据库 在开始销毁表单之前关闭更新表单第一个表单标签(缺少)。


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>


当我使用[input type =“file”]选择文件时,在html中,那么它存储在我们本地的哪里

我需要从一个本地驱动器获取文件,然后粘贴到另一个本地驱动器中。条件:我不应该通过浏览文件夹来执行此操作,我应该在 UI(网站)本身中执行此操作。我用了 ...


从数据库中选择 SELECT 选项后如何显示/隐藏 DIV?

这是选择选项的代码; 这是选择选项的代码; <div class="modal-body row"> <form role="form" action="patient/addNew" class="clearfix" method="post" enctype="multipart/form-data"> <div class="form-group col-md-6"> <label for="exampleInputEmail1"><?php echo lang('categorie'); ?></label> <select class="form-control m-bot15" name="categorie" value='' id="p_category"> <option value="#"> Sélectionner catégorie</option> <?php foreach ($categories as $category) { ?> <option value="category"><?php if (!empty($setval)) { if ($category->category == set_value('category')) { echo 'selected'; } } if (!empty($patient->category)) { if ($category->category == $patient->category) { echo 'selected'; } } ?> > <?php echo $category->category; ?> </option> <?php } ?> </select> </div> 这是必须显示/隐藏的 div: <label for="exampleInputEmail1"><?php echo lang('name_Us'); ?></label> <input type="text" class="form-control" name="name_husband" id="nameUs" placeholder=""> <label for="exampleInputEmail1"><?php echo lang('number_pre'); ?></label> <input type="number" class="form-control" name="number_pre" id="nbreEnf" placeholder=""> </div> 这是 JavaScript 代码: $('.divUs').hide(); $(document.body).on('change', '#p_category', function () { var v = $("select.p_category option:selected").val() if (v == 'Fe_Ence') { $('.divUs').show(); } else { $('.divUs').hide(); } }); }); 我希望如果选择了元素(Fe_Ence),则可以显示 div,否则,它保持隐藏 例如,您可以使用 :has 选择器 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <div id="thingtohide"> <h1>Hello</h1> </div> <div id="checkbox"> <input type="checkbox"> </div> <style> body:has(#checkbox input:checked) #thingtohide { visibility: hidden; } </style> </body> </html> 因此,如果父元素有一个选中的复选框,那么您可以定位与该父元素不同的子元素。


绑定了formControlName后,如何在html中使用它?

我当前有问题的 html 部分是这样的 ... 我的 html 当前有问题的部分是这个 <div class="psi-list"> <div class="flex-row" *ngFor="let item of psiList; index as i"> <p class="row-psi">{{ item.psi }}</p> <button class="icon-btn" (click)="deletePsi(item.psi)"><i class="cil-trash"></i></button> <button class="icon-btn" (click)="item.toggle = !item.toggle"><i class="cil-pen-alt"></i></button> <form [formGroup]="psiEditForm" id="psi-edit-form" class="form-horizontal" [hidden]="!item.toggle"> <input class="psi-input" type="text" placeholder="Update PSI here..." [(ngModel)]="psiEdit" [ngClass]="{'is-valid': !checkControlValidation(psiEditForm.controls.psi) && psiEditForm.controls.psi.touched, 'is-invalid': checkControlValidation(psiEditForm.controls.psi)}" (keydown.enter)="!psiEditForm.controls.psi.invalid ? editPsi(item.psi) : clearPsiEdit()" formControlName="psi" /> <div class="help-block validation-warning" *ngIf="checkControlValidation(psiEditForm.controls.psi)"><i class="fa fa-exclamation fa-lg"></i>Please Enter a Valid 2 Letter PSI</div> </form> </div> </div> 我使用 formControlName“psi”将控件传递给 .ts 文件中的 checkControlValidation 方法。然而,这会导致功能问题。每当我在一个输入框中输入内容时,它都会将其输入到 *ngFor 中的所有输入框中。 当我将表单控件名称更改为这个时 - [formControlName]="item.psi" 它将名称绑定到与其相关的项目,因此理论上我可以通过它来解决我的问题。但是,当我将 psiEditForm.controls.psi 的所有实例更改为 psiEditForm.controls.item.psi 时,我收到很多 TS2339 错误。 我有什么想法可以使用它吗?抱歉,我知道这可能措辞很糟糕 尝试这样 <div class="psi-list"> <div class="flex-row" *ngFor="let item of psiList; index as i"> <p class="row-psi">{{ item.psi }}</p> <button class="icon-btn" (click)="deletePsi(item.psi)"><i class="cil-trash"></i></button> <button class="icon-btn" (click)="item.toggle = !item.toggle"><i class="cil-pen-alt"></i></button> <form [formGroup]="psiEditForm" id="psi-edit-form" class="form-horizontal" [hidden]="!item.toggle"> <input class="psi-input" type="text" placeholder="Update PSI here..." [(ngModel)]="psiEdit" [ngModelOptions]="{standalone: true}" [ngClass]="{'is-valid': !checkControlValidation(psiEditForm.controls.psi) && psiEditForm.controls.psi.touched, 'is-invalid': checkControlValidation(psiEditForm.controls.psi)}" (keydown.enter)="!psiEditForm.controls.psi.invalid ? editPsi(item.psi) : clearPsiEdit()" formControlName="psi" /> <div class="help-block validation-warning" *ngIf="checkControlValidation(psiEditForm.controls.psi)"> <i class="fa fa-exclamation fa-lg"></i>Please Enter a Valid 2 Letter PSI </div> </form> </div> </div>


如何控制列表元素抛出键盘事件

https://stackblitz.com/edit/react-o1ra7c 用户搜索结果后,用户尝试使用键盘事件箭头需要向下移动。 https://stackblitz.com/edit/react-o1ra7c 用户搜索结果后,用户尝试使用键盘事件箭头需要向下移动。 <div> <input onChange={handleSearchChange}/> <div css={countryDataCss}> {countryList?.map((country) => ( <div key={country.countryCode}> <span css={countryCss}>{country.countryName}</span> <span css={countryDialCodeCss}> {country.countryDialNo} </span> </div> ))} </div> </div> 您可以使用 javascirpt 事件 onkeydown,对于 React 来说是 onKeyDown,它提供了所需的行为,请检查下面的 stackblitz! import React from 'react'; import './style.css'; import { useState } from 'react'; export default function App() { const [searchText, setSearchText] = useState(''); const [selectedCountry, setSelectedCountry] = useState('SG'); const [activeIndex, setActiveIndex] = useState(0); const [selectedDialCode, setSelectedDialCode] = useState('+65'); const countryCodeListResponse = [ { countryCode: 'IND', countryDialNo: '+91', countryName: 'India' }, { countryCode: 'SG', countryDialNo: '+65', countryName: 'Singpare' }, ]; const [countryList, setCountryList] = useState(countryCodeListResponse); function handleSearchChange(e) { const searchText = e.target.value.toLowerCase(); if (countryCodeListResponse) { const updatedList = countryCodeListResponse .filter((el) => el.countryName.toLowerCase().includes(searchText)) .sort( (a, b) => a.countryName.toLowerCase().indexOf(searchText) - b.countryName.toLowerCase().indexOf(searchText) ); setSearchText(searchText); setCountryList(updatedList); } } const onSelectCountry = (code, dialCode) => { setSelectedCountry(code); setSelectedDialCode(dialCode); setSearchText(''); setCountryList(countryCodeListResponse); }; const onKeyDown = (event) => { console.log(event); switch (event.keyCode) { case 38: // arrow up if (activeIndex > 0 && activeIndex <= countryList.length - 1) { setActiveIndex((prev) => prev - 1); } break; case 40: // arrow down if (activeIndex >= 0 && activeIndex < countryList.length - 1) { setActiveIndex((prev) => prev + 1); } break; case 13: const country = countryList[activeIndex]; onSelectCountry(country.countryCode, country.countryDialNo); break; default: break; } }; return ( <div class="dropdown"> <div class="search"> <div> <span>{selectedCountry}</span> <span>{selectedDialCode}</span> </div> <input class="search-input" onKeyDown={(e) => onKeyDown(e)} placeholder="Search" value={searchText} onChange={handleSearchChange} /> </div> <div class="list"> {countryList?.map((country, index) => ( <div onKeyDown={(e) => onKeyDown(e)} className={index === activeIndex ? 'active' : ''} tabIndex="0" key={country.countryCode} onClick={() => onSelectCountry(country.countryCode, country.countryDialNo) } > <span>{country.countryName}</span> <span>{country.countryDialNo}</span> </div> ))} </div> </div> ); } 堆栈闪电战


如何在VUE中使用参数访问v-model值

我想使用参数访问 v-model 值,我尝试下面的代码 我想使用参数访问 v-model 值,我尝试下面的代码 <template> <div v-for="(item, idx) in data"> <input :id="item" :v-model="item"></input> <button @click="submitTest(item)"> testbtn </button> </div> </template> <script setup> var data = {'test1': 'val1', 'test2': 'val2'} function submitTest(itemParam){ alert(itemParam.value) } </script> 实际上在submitTest函数(警报行)中,它不访问输入标签v-model,而是访问itemParam(字符串值本身)值。我想要的是使用由项目参数传递的参数访问输入“项目值”。 我尝试了上面的代码,结果,它实际上访问了“itemParam”字符串值本身,而不是传递参数。 在Vue.js中,您应该使用v-model进行双向数据绑定。 v-model 指令是绑定数据以形成输入并更新用户输入数据的便捷简写。但是,它不能直接用作 prop 或作为参数传递。相反,您可以传递整个对象并在方法中使用它。 以下是修改代码的方法: <template> <div v-for="(item, idx) in data" :key="idx"> <input :id="item" v-model="item.value"></input> <button @click="submitTest(item)">testbtn</button> </div> </template> <script setup> const data = ref([ { id: 'input1', value: '' }, { id: 'input2', value: '' }, // ... other items ]); function submitTest(item) { alert(item.value); } </script> 在此示例中,数据数组中的每个项目都是一个具有 id 和 value 属性的对象。 v-model 指令绑定到 item.value。当您单击按钮时,将使用整个项目对象调用 SubmitTest 函数,您可以从那里访问 value 属性。 确保在设置脚本中使用 ref 创建对数据数组的反应性引用。 注意: :key="idx" 添加到 中,为循环中的每个项目提供唯一的键。这有助于 Vue.js 在数组更改时高效更新和重新渲染组件。


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


从数据库表中选择选择选项后如何显示/隐藏隐藏的 Div?

以下是选择选项的代码: 这是选择选项的代码: <div class="modal-body row"> <form role="form" action="patient/addNew" class="clearfix" method="post" enctype="multipart/form-data"> <div class="form-group col-md-6"> <label for="exampleInputEmail1"><?php echo lang('categorie'); ?></label> <select class="form-control m-bot15" name="categorie" value='' id="p_category"> <option value="#"> Sélectionner catégorie</option> <?php foreach ($categories as $category) { ?> <option value="category"><?php if (!empty($setval)) { if ($category->category == set_value('category')) { echo 'selected'; } } if (!empty($patient->category)) { if ($category->category == $patient->category) { echo 'selected'; } } ?> > <?php echo $category->category; ?> </option> <?php } ?> </select> </div> 这是应该显示/隐藏的 Div: <div class="form-group col-md-6" id="divCacher" style="display: none"> <label for="exampleInputEmail1"><?php echo lang('name_husband'); ?></label> <input type="text" class="form-control" name="name_Us" id="nameUs" placeholder=""> <label for="exampleInputEmail1"><?php echo lang('number_pregnancy'); ?></label> <input type="number" class="form-control" name="number_pregnancy" id="nbreEnfants" placeholder=""> </div> 这是 JavaScript 代码: $(document).ready(function () { $('.divCacher').hide(); $(document.body).on('change', '#p_category', function () { var v = $("select.p_category option:selected").val() if (v == 'Fe_Ence') { $('.divCacher').show(); } else { $('.divCacher').hide(); } }); }); 我希望如果我们选择 Fe_Ence 类别,则 div 会显示,否则,它会保持隐藏 您需要将 $category 设置为选项值更改此: <option value="category"> 对此: <option value="<?=$category?>"> 以下是适用于更多此类情况的示例: <!--SELECT INPUT--> <select id="p_category"> <option value=""> Sélectionner catégorie</option> <?php foreach ($categories as $category): ?> <option value="<?=$category?>"><?=$category?> <?php endforeach;?> </select> <!--Container List--> <div class="cat-container" data-id="test1"> <h1>This is Test1 Category</h1> </div> <div class="cat-container" data-id="Fe_Ence"> <h1>This is Fe_Ence Category</h1> </div> <div class="cat-container" data-id="test3"> <h1>This is test3 Category</h1> </div> // Javascript code checkCategory(); $("#p_category").on('change', checkCategory) function checkCategory() { $('.cat-container').hide() const selected = $('#p_category').val() if (!selected) return; $(`[data-id=${selected}`).show() }


如何在Bootstrap中管理较小尺寸的页面?

.$s['姓氏']. <div class="input-group col-sm-10"> <span class="input-group-addon col-sm-4 text-right border">.$s['Surname'].</span> <input id="msg" type="text" class="form-control col-sm-6" name="msg" placeholder="Enter Marks"> 嗨,我尝试使用 2 列,但是在手机上,控件的行为似乎有所不同 如何让控件在小屏幕上保持常规尺寸? 谢谢你。 当你在代码中说 col-sm-6 意味着从小尺寸(576px)开始采用这个尺寸 <div class="container-fluid"> <div class="row"> <div class="col-12 col-sm-8 col-md-6"></div> <div class="col-12 col-sm-4 col-md-6"></div> </div> </div> // <div class="col-12 col-sm-8 col-md-6"></div> 这段代码传达的概念是 col-12:通常占据所有小于small的列 col-sm-8:从小模式开始占据 8 列(576px) col-md-6:从中模式开始占据 6 列(768px) 我们还可以按需使用col-lg,这取决于我们的需求。 我希望我明白你的意思并且我能够很好地帮助你 你应该尝试下面的代码, <div class="container"> <div class="row"> <div class="col"> Here col is used for auto width (if row has multiple elements in column so col width will be adjusted automatically by dividing them) </div> </div> </div> 或 <div class="container"> <div class="row"> <div class="col-12"> Here col-12 is used so this will get entire width of the viewport (12 grids) as it is specified.. </div> <div class="col"> Here col is used so as above div has col-12 class so this col will get auto width and there is no more columns in this row so this will get 100% of width. </div> </div> </div> 注意:适用于移动设备等小型设备(<576px) only col is used and col itself uses all 12 grids but if we have multiple columns in row and we want to give different grids to them, then we have to specify as col-6, col-4, col-12 etc as per requirement... 有关更多详细信息,我已附加一些链接并仅供参考... 引导网格系统 谢谢... 阿拉普·乔希


php 中的用户欢迎消息

如何在 php.ini 中创建用户欢迎消息这样已经登录的用户就能够看到他的用户名。 我有这段代码,但它似乎不起作用。 如何在 php.ini 中创建用户欢迎消息这样已经登录的用户就能够看到他的用户名。 我有这个代码,但它似乎不起作用。 <?php $con = mysql_connect("localhost","root","nitoryolai123$%^"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("school", $con); $result = mysql_query("SELECT * FROM users WHERE Username='$username'"); while($row = mysql_fetch_array($result)) { echo $row['Username']; echo "<br />"; } ?> 我正在尝试利用在此登录表单中输入的数据: <form name="form1" method="post" action="verifylogin.php"> <td> <table border="0" cellpadding="3" cellspacing="1" bgcolor=""> <tr> <td colspan="16" height="25" style="background:#5C915C; color:white; border:white 1px solid; text-align: left"><strong><font size="2">Login User</strong></td> </tr> <tr> <td width="30" height="35"><font size="2">Username:</td> <td width="30"><input name="myusername" type="text" id="idnum" maxlength="5"></td> </tr> <tr> <td width="30" height="35" ><font size="2">Password:</td> <td width="30"><input name="mypassword" type="password" id="lname" maxlength="15"></td> </tr> <td align="right" width="30"><td align="right" width="30"><input type="submit" name="Submit" value="Submit" /></td> <td align="right" width="30"><input type="reset" name="Reset" value="Reset"></td></td> </tr> </form> 但是这个 verifylogin.php 似乎很碍事。 <?php $host="localhost"; $username="root"; $password="nitoryolai123$%^"; $db_name="school"; $tbl_name="users"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count==1){ session_register("myusername"); session_register("mypassword"); header("location:userpage.php"); } else { echo "Wrong Username or Password"; } ?> 我该怎么做?当我运行它时,我总是收到此错误: Notice: Undefined variable: username in C:\wamp\www\exp\userpage.php on line 53 您能推荐一个更简单的方法来实现同样的目标吗? $result = mysql_query("SELECT * FROM users WHERE Username='$username'"); 你忘记从某处定义和填充$username 您还需要添加 exit();在以下代码之后: session_register("myusername"); session_register("mypassword"); header("location:userpage.php"); exit(); ## EXIT REQUIRED 如果您不添加此内容并且客户端刷新,则会提示“您确定要重新提交已发布的变量吗?”如果他们单击“是”,那么您所有的登录逻辑将再次执行。在这种情况下,这可能不是致命的事情,但无论如何你都应该拥有它。 最重要的是:如果新用户登录,需要显示不同的名称,而不是显示以前的名称


如何使用 blazor <InputDate /> 标签使用当地文化来格式化日期

我正在我的 Blazor 应用程序中使用该标签。但是我如何使用我自己的文化来格式化日期? 我正在我的 Blazor 应用程序中使用该标签。但是我如何使用我自己的文化来格式化日期? <InputDate class="form-control" @bind-Value="@ValidDate" @bind-Value:culture="nl-BE" @bind-Value:format="dd/MM/yyyy" /> 问候 迪特尔 答案是@bind-Value:format,就像这样 @page "/" <EditForm Model="@CurrentPerson"> <InputDate @bind-Value="@CurrentPerson.DateOfBirth" @bind-Value:format="dd/MM/yyyy"/> </EditForm> @code { Person CurrentPerson = new Person(); public class Person { public DateTime DateOfBirth { get; set; } = DateTime.Now; } } 还可以选择使用bind-Value:culture。 无法设置InputDate或<input type="date">的格式。这取决于浏览器设置。用户可以更改浏览器的语言。但您无法从 HTML 更改它。如果您确实需要自定义格式,则必须使用InputText或<input type="text">。我建议使用一些 javascript 库,例如 jQuery UI datepicker。 该解决方案对我不起作用。我是这样工作的: @代码{ 仅私人日期? _geboortedatum; private string GeboortedatumFormatted { get => _geboortedatum?.ToString("dd-MM-yyyy") ?? ""; set { if (DateOnly.TryParse(value, out var newDate)) { _geboortedatum = newDate; } } } } 地质学 _geboortedatum" class="text-danger" />


使用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 中的命令行 '''


更改垫输入的波纹颜色

我现在一直在努力了解如何手动更改元素的波纹颜色,但我似乎无法让它以任何方式工作。 我现在一直在努力研究如何手动更改 <mat-input> 元素的波纹颜色,但我似乎无法让它以任何方式工作。 <input matInput type="number" (keydown)="updateManualPage(1)" placeholder="Filter" formControlName="filterParam1"> 我已经尝试了CSS中我能想到的一切,.mat-form-field-underline,.mat-form-field-ripple,包括我使用::after和::before选择器从另一个SO问题/答案中无耻地撕掉的一大块类,尝试使用 ::ng-deep、!important,但似乎没有任何东西可以改变从 @import "../node_modules/@angular/material/prebuilt-themes/indigo-pink.css"; 导入的蓝色波纹的颜色 编辑:只需更好地阅读 API,所以我发现波纹后出现的边框颜色来自 <mat-form-field> 元素,该元素有一个颜色选择器。但是,该颜色选择器只能具有“primary”、“accent”和“warn”值。所以现在我想知道如何插入自定义颜色。 设法弄清楚了,原来如此 ::ng-deep .mdc-text-field--filled:not(.mdc-text-field--disabled) .mdc-line-ripple::after { border-bottom-color: *X* !important; }


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