【问题标题】:small tag not works with input tag小标签不适用于输入标签
【发布时间】:2019-01-30 22:47:54
【问题描述】:

编码是,

<input type="tel" required #phone=ngModel pattern='^\d{10}$' [ngClass]="{'is-invalid': !phone.valid}" name="phone" class="form-control" [(ngModel)]="userModel.phone">
  <small [class.d-none]=”phone.valid || phone.untouched”>Phone number is required and must be ten digits</small>

输出控制台给出,

compiler.js:2427 Uncaught Error: Template parse errors:
Parser Error: Unexpected token Lexer Error: Unexpected character [”] at column 1 in expression [”phone.valid] at column 2 in [”phone.valid] in ng:///AppModule/AppComponent.html@58:9 ("-invalid': !phone.valid}" name="phone" class="form-control" [(ngModel)]="userModel.phone">
  <small [ERROR ->][class.d-none]=”phone.valid || phone.untouched”>Phone number is required and must be ten digits</smal"):

我使用双单引号作为''而不是双引号作为“,它给出的错误消息是,

未捕获的错误:模板解析错误: 意外的结束标签“小”。当标签已被另一个标签关闭时,可能会发生这种情况。有关详细信息,请参阅https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags ("ll [class.d-none]=''phone.valid || phone.untouched''>电话号码是必填项,必须是十位数字[ERROR ->]

【问题讨论】:

  • 尝试用"替换
  • Unexpected character [”]
  • 我使用双单引号作为'',它给出的错误信息是,未捕获的错误:模板解析错误:意外的结束标记“小”。当标签已被另一个标签关闭时,可能会发生这种情况。有关详细信息,请参阅w3.org/TR/html5/… ("ll [class.d-none]=''phone.valid || phone.untouched''>电话号码为必填项,必须为十位数字[ERROR ->]
  • 我使用双单引号作为'' 这不是错误所表示的。它说它遇到了单个 字符。您很可能使用文本编辑器来编写使用字体格式的代码。使用不对字符应用格式的编辑器。
  • 我用了",得到了输出。

标签: javascript html css angular


【解决方案1】:

你用错了引号:

[class.d-none]=”phone.valid || phone.untouched”

应该改为:

[class.d-none]="phone.valid || phone.untouched"

【讨论】:

  • 什么是''符号,我使用双单引号作为'',它给出的错误消息是,未捕获的错误:模板解析错误:意外的结束标记“小”。当标签已被另一个标签关闭时,可能会发生这种情况。有关更多信息,请参阅 w3.org/TR/html5/…(“ll [class.d-none]=''phone.valid || phone.untouched''>电话号码是必需的,并且必须是十位数字[错误 -> ]
  • 您前进到下一个错误。也许您打扰阅读错误消息?一开始就已经帮到你了。 It may happen when the tag has already been closed by another tag. 发布整个sn-p。
  • 我刚刚复制了你的代码并粘贴了它,但是这个符号是什么以及如何使用键盘输入这个符号,
  • @David 真的吗?这是一个没有任何格式的双引号。也称为直引号。按 SHIFTSHIFT 左侧的键。但是,正如我之前所说,使用不对代码应用字体格式的编辑器,否则你会得到一开始就导致问题的智能引号 (“”)。
  • 或者,NotePad++,或者Visual Studio Code,或者Visual Studio Community,都是免费的。
【解决方案2】:

替换

<small [class.d-none]=”phone.valid || phone.untouched”>Phone number is required and must be ten digits</small>

与:

<small [class.d-none]="phone.valid || phone.untouched">Phone number is required and must be ten digits</small>

【讨论】:

  • 什么是''符号,我使用双单引号作为'',它给出的错误消息是,未捕获的错误:模板解析错误:意外的结束标记“小”。当标签已被另一个标签关闭时,可能会发生这种情况。有关更多信息,请参阅 w3.org/TR/html5/…(“ll [class.d-none]=''phone.valid || phone.untouched''>电话号码是必需的,并且必须是十位数字[错误 -> ]
  • 我刚刚复制了你的代码并粘贴了它,但是如何使用键盘输入这个符号,
猜你喜欢
  • 2021-01-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-07-15
相关资源
最近更新 更多