angular - 角度启动抛出错误中的自动调整大小
问题描述
当我尝试使用 autoresize 属性时,出现一个错误:
Type 'string' is not assignable to type 'boolean'
模板代码是:
<textarea [rows]="5" [cols]="30" id="float-input3" pInputTextarea autoResize="true"></textarea>
我像在文档中一样使用这个属性,我不知道什么不起作用。
我已经尝试使用autoResize="autoResize"
但我有同样的错误。
文档https://www.primefaces.org/primeng/showcase/#/inputtextarea
你知道什么不起作用或我做的不对吗?
我使用 Primeng 11.2.0 和 Angular 11。
谢谢你的帮助
解决方案
Pretty sure you need to add a new public property to your component:
public autoResize: boolean = true;
...and then bind it into the template like:
<textarea ... [autoResize]="autoResize"></textarea>
In your examples you didn't have the [ ]
around the property. Angular was getting confused as to whether you wanted to pass "true"
as a string or true
as a boolean. When it is explicitly defined in the component with :boolean
, angular can be assured of what the type is.
推荐阅读
- java - JDK 1.8.x 的要求检查失败!检测到的版本:3.0.0
- reactjs - 如果使用带有元素样式 Reactjs 的 useRef() 条件,UI 不会更新
- azure - 为什么此 Azure 资源管理器模板验证失败?
- kubernetes - Kubernetes 生命周期命令未运行
- node.js - 如何在 MongoDB 中管理连接
- r - 匹配相同的列
- python - 从 Pandas Dataframe 创建 Networkx 有向图时如何创建多线节点标签
- python - 如何使用moviepy反转视频和音频剪辑?
- sql - 如何在Postgres中按年月按最大(日期)组获取行?
- python - 我如何检查指定用户是否是有效用户(也在服务器中)(discord.py)