在这篇文章中,我们将为您详细介绍“必需”属性在PHPHTML中不起作用的内容,并且讨论关于html必填属性的相关问题。此外,我们还会涉及一些关于-webkit-text-security:光盘;css
在这篇文章中,我们将为您详细介绍“必需”属性在 PHP HTML 中不起作用的内容,并且讨论关于html必填属性的相关问题。此外,我们还会涉及一些关于-webkit-text-security:光盘; css 属性在 Firefox 浏览器中不起作用、@media 打印 { 分页前; page-break-after} 属性在 IONIC角度中不起作用 在 .ts 文件中在 css 中、@Value 属性在 spring 组件中返回 null、AllowUserToAddRow 属性在 .NET/C# (DataGridView) 中不起作用的知识,以帮助您更全面地了解这个主题。
本文目录一览:- “必需”属性在 PHP HTML 中不起作用(html必填属性)
- -webkit-text-security:光盘; css 属性在 Firefox 浏览器中不起作用
- @media 打印 { 分页前; page-break-after} 属性在 IONIC角度中不起作用 在 .ts 文件中在 css 中
- @Value 属性在 spring 组件中返回 null
- AllowUserToAddRow 属性在 .NET/C# (DataGridView) 中不起作用
“必需”属性在 PHP HTML 中不起作用(html必填属性)
如何解决“必需”属性在 PHP HTML 中不起作用
我试图为空字段添加验证。如果字段为空,则不会提交表单。但是我的“必需”属性不起作用。
Birthdate:
<select name="month" required>
<option value="0" required>Select Month</option>
<?PHP
for( $m = 1; $m <= 12; $m++ )
{
$num = str_pad( $m,2,STR_PAD_LEFT );
$month = date( ''F'',mktime( 0,$m + 1,0 ) );?>
<option value="<?PHP echo $num;?>"><?PHP echo $month; ?></option>
<?PHP
}
?>
</select>
</select>
解决方法
<option>
不需要''required'',只需在<select>
中就足够了。如果您想获得第一个作为默认值,请使用“selected”而不是“required”。
选项标签没有必需的属性。
<select name="month" required>
<option value="0">Select Month</option>
<?php
for( $m = 1; $m <= 12; $m++ )
{
$num = str_pad( $m,2,STR_PAD_LEFT );
$month = date( ''F'',mktime( 0,$m + 1,0 ) );?>
<option value="<?php echo $num;?>"><?php echo $month; ?></option>
<?php
}
?>
</select>
https://developer.mozilla.org/es/docs/Web/HTML/Element/option
,您可以在第一个选项中取消设置值。示例:
<select name="month" required>
<option value="" required>Select Month</option>
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">...</option>
</select>
-webkit-text-security:光盘; css 属性在 Firefox 浏览器中不起作用
如何解决-webkit-text-security:光盘; css 属性在 Firefox 浏览器中不起作用
-webkit-text-security:光盘; css 属性在 Firefox 浏览器中不起作用
在 mozilla 中是否有相同的替代方案。请帮忙
解决方法
更新代码:
@font-face{
font-family: text-security-disc;
src: url("https://raw.githubusercontent.com/noppa/text-security/master/dist/text-security-disc.woff");
}
input {
font-family: text-security-disc;
-webkit-text-security: disc;
}
<input type="text">
注意:- 如果您不想将 password
作为输入类型, 我能想到的唯一方法是使用“光盘”之类的字体进行输入。我不建议这样做,因为任何人都可以将密码复制粘贴到文本编辑器并查看它。如果你想继续,这里是 github 存储库的 link。 (我没有测试过,所以我不确定)
@media 打印 { 分页前; page-break-after} 属性在 IONIC角度中不起作用 在 .ts 文件中在 css 中
如何解决@media 打印 { 分页前; page-break-after} 属性在 IONIC角度中不起作用 在 .ts 文件中在 css 中
假设它是一个示例代码?
<div id="print-div">
<p>Lorem ipsum dolor sit amet page 1.</p>
<ion-label>page break here</ion-label>
<p>Lorem ipsum dolor sit amet page 2.</p>
</div>
我想打印这部分,第一段在第一页,第二段在下一页。
在 .ts 文件中
printThis(){
let backup = document.body.innerHTML;
let divcontent = document.getElementById(''print-div'').innerHTML;
document.body.innerHTML = divcontent;
window.print();
document.body.innerHTML = backup;
}
在 css 中
@media print {
ion-label{
page-break-before: always !important;
}
}
但这不会在打印时破坏页面。 所有数据都打印在一页中,如果内容大于一页,它仍然打印任何一页的数据。
我试过
page-break-before: always;
page-break-after: always;
break-after: always;
但是什么都没发生。
如果有人帮助我了解如何在 ionic 中使用 page-break 属性。 我会很感激的。
解决方法
问题:
ion-content 组件有一个绝对定位的内部 div。由于 ionic 使用带有 shadow-root 的 web-components 并且定位未公开为 css 变量,因此无法使用 css 样式表设置此样式属性。但是:分页符不适用于绝对定位的元素 w3schools
解决方案:
使用JS操作shadow-root并将定位设置为relative。 github: ionic-print-test
我遇到了同样的问题,并通过使用事件侦听器 onbeforeprint
和 onafterprint
解决了它。这是一个带有 angular 的 ionic 示例,但逻辑可以很容易地重构为 react 或 vue。 ionic-print-test:issue
print.service.ts
,
import { DOCUMENT } from ''@angular/common'';
import { Inject,Injectable } from ''@angular/core'';
@Injectable({
providedIn: ''root'',})
export class PrintService {
constructor(@Inject(DOCUMENT) private document: HTMLDocument) {}
init() {
window.onbeforeprint = () => this.setPrintStyles(true);
window.onafterprint = () => this.setPrintStyles(false);
}
private setPrintStyles(add: boolean) {
this.document.querySelectorAll(''ion-content'').forEach((element) => {
const scroll = element.shadowRoot.querySelector(''.inner-scroll'') as HTMLElement;
if (add) {
scroll.style.position = ''relative'';
} else {
scroll.style.removeProperty(''position'');
}
});
}
}
对于我添加这项工作。离子 4,角 8
@media print {
body {
position: relative !important;
}
}
https://medium.com/@Idan_Co/angular-print-service-290651c721f9
@Value 属性在 spring 组件中返回 null
如何解决@Value 属性在 spring 组件中返回 null
我在 spring boot 中创建了一个验证器组件,我在 application.properties
中保留了一个正则表达式。我已经使用 @Value
注释来获取组件中正则表达式的值,并且我正在任何方法或构造函数之外编译模式,这给了我空指针异常,因为当时正则表达式没有获得它的值。但是当我将模式移动到某种方法时,它工作正常。这是为什么?
为什么即使使用@Component 创建对象,@Value 也不起作用
看下面的代码:
返回 NullPointerException 的代码:
@Component
public class ValidString implements ConstraintValidator<ValidString,String> {
@Value("${user.input.regex}")
private String USER_INPUT_REGEX;
private Pattern USER_INPUT_PATTERN = Pattern.compile(USER_INPUT_REGEX);
@Override
public boolean validate(String userInput,ConstraintValidatorContext constraintValidatorContext) {
return USER_INPUT_PATTERN.matcher(userInput).find();
}
}
代码工作正常:
@Component
public class ValidString implements ConstraintValidator<ValidString,String> {
@Value("${user.input.regex}")
private String USER_INPUT_REGEX;
private Pattern USER_INPUT_PATTERN;
@Override
public boolean validate(String userInput,ConstraintValidatorContext constraintValidatorContext) {
USER_INPUT_PATTERN = Pattern.compile(USER_INPUT_REGEX);
return USER_INPUT_PATTERN.matcher(userInput).find();
}
}
此外,如果您能解释为什么第一个不起作用而第二个起作用,那就太好了。
application.properties
user.input.regex = ^[a-zA-Z0-9/\\\\-_ \\\\s+]*$
解决方法
字段初始值设定项(有问题的第一个示例)在 类构造函数执行期间执行。 @Value
由 Spring 注入 构造函数返回后,使用反射。这意味着您不能拥有使用 @Value
注入值的初始化程序。
这个问题可以通过构造函数或setter注入来解决:
// Inject using constructor
@Component
public class ValidString implements ConstraintValidator<ValidString,String> {
private Pattern USER_INPUT_PATTERN;
@Autowired
public ValidString(@Value("${user.input.regex}") String regex) {
this.USER_INPUT_PATTERN = Pattern.compile(regex);
}
,
// Inject using setter method
@Component
public class ValidString implements ConstraintValidator<ValidString,String> {
private Pattern USER_INPUT_PATTERN;
@Autowired
private void setUserInputRegex(@Value("${user.input.regex}") String regex) {
this.USER_INPUT_PATTERN = Pattern.compile(regex);
}
模式 USER_INPUT_PATTERN 在 spring 过程之前。 类 ValidString 对象初始顺序为:->process field initial->constructor -> inject field 所以,当你使用1个代码时,它必须是空点,因为字段没有注入
AllowUserToAddRow 属性在 .NET/C# (DataGridView) 中不起作用
如何解决AllowUserToAddRow 属性在 .NET/C# (DataGridView) 中不起作用
我有一个链接到 BindingSource 的 DataGridView
- AllowUserToAddRow 属性为 DGV 设置为 true
- AllowNew 将绑定源的属性设置为 true
- 与 datagridview 的 ReadOnly 属性没有冲突
我尝试为绑定源中引用的类型添加一个参数较少的公共构造函数,但也不起作用。
PS:我使用 ToBindingList() 而不是 ToList() 方法来影响数据源。
在设计器中,DGV 显示了带星号的空行(展示了添加行的能力),但是一旦运行项目它就消失了,所以我无法在 DGV 中添加任何行。
有任何线索吗?
我们今天的关于“必需”属性在 PHP HTML 中不起作用和html必填属性的分享已经告一段落,感谢您的关注,如果您想了解更多关于-webkit-text-security:光盘; css 属性在 Firefox 浏览器中不起作用、@media 打印 { 分页前; page-break-after} 属性在 IONIC角度中不起作用 在 .ts 文件中在 css 中、@Value 属性在 spring 组件中返回 null、AllowUserToAddRow 属性在 .NET/C# (DataGridView) 中不起作用的相关信息,请在本站查询。
本文标签: