Type ‘number‘ is not assignable to type ‘string‘
document.getElementById('gohanCost').innerHTML = 0;
报错:
Type ‘number’ is not assignable to type ‘string’
类型“number”不可分配给类型“string”
解决方法
document.getElementById('gohanCost').innerHTML = "" + 0;
or
document.getElementById('gohanCost').innerHTML = String(0);
Type ‘number‘ is not assignable to type ‘string‘相关推荐
- TypeScript报错 Type ‘number‘ is not assignable to type ‘never‘
最近回来写angular,在做组件拆分时,父组件往子组件注入number类型的数组时报错 原因: 子组件中声明注入属性 @Input() data1 = [];时,未声明属性类型 将变量类型声明一 ...
- typescript error TS2322: Type ‘Timeout‘ is not assignable to type ‘number‘.
源码 const timer:number = setTimeout(()=>{},1) 报错 typescript error TS2322: Type 'Timeout' is not as ...
- Type ‘string | null‘ is not assignable to type ‘string‘. Type ‘null‘ is not assignable to type ‘
报错如下: Type 'string | null' is not assignable to type 'string'. Type 'null' is not assignable to type ...
- TS2322 Type ‘void‘ is not assignable to type ‘MouseEventHandlerHTMLElement
问题:TS2322 Type 'void' is not assignable to type 'MouseEventHandlerHTMLElement 实例: 都是在类似这种"----- ...
- vue3+ts Type ‘xxx[]‘ is not assignable to type ‘never[]‘
原因是:ts默认初始化空数组为 never[] 类型,跟你赋值的数据类型不匹配 修改为:arr_data: [] as any[],即可 vue3 keep-alive+vuex配合使用(简单易用)
- h5 android数字键盘,【笔记】移动端H5数字键盘input type=number的处理(IOS和Android)...
在Vue中的项目,基于VUX-UI开发,一个常见的需求: 1.金额输入框 2.弹出数字键盘 3.仅支持输入两位小数,限制最大11位数,不允许0开头 第一,首先想到额就是在VUX-UI中制定type=n ...
- 动手写个数字输入框1:input[type=number]的遗憾
前言 最近在用Polymer封装纯数字的输入框,开发过程中发现不少坑,也有很多值得研究的地方.本系列打算分4篇来叙述这段可歌可泣的踩坑经历: <动手写个数字输入框1:input[type=nu ...
- type=number和type=tel的区别
众所周知,HTML5加入了新的input类型 number,这是方便数量输入的.如果是在移动端中,属性type="number"和type="tel"会唤起系统 ...
- error TS2322: Type ‘WritableComputedRef<string>‘ is not assignable to type ‘string‘ 解决方法
前言 在 Vue3 + TypeScript + pinia 项目中,使用 get() set() 定义计算属性时,出现 '不能将类型"WritableComputedRef<stri ...
最新文章
- Paddle下的Tensor运算以及简单回归问题
- 狂风暴雨——电闪雷鸣篇:数据流层核心思想揭秘
- 应该始终以PreparedStatement代替Statement
- ServiceStack.Redis的问题与修正
- 如何通过css选取元素以及封装了获取,删除css的相关操作
- STL的forward_list链表
- 自问自答 学习系列(1):从图像分类,到损失函数,到神经网络
- 几种常用的数字滤波器
- iOS开发网络篇—Reachability检测网络状态
- c可以 char* 赋值但是c++不可以_雷佳音的妻子完全可以女团C位出道,这么有气质的女人,谁能不爱...
- 一个 冒泡排序 和 选择排序 的简单c程序
- 分布式日志平台--ELKStack实践
- 不推荐使用getResources()。getColor()[重复]
- python优先级排序_用Python实现优先级队列的3种方法
- this.$router.push跳转到原来页面不刷新的问题解决
- Python3.6+selenium2.53.6自动化测试_禅道新增BUG(一)(本地禅道)
- 语音数据增强算法汇总(附代码)
- 自己搭建ant design框架
- ep服务器修改时间,BIOS揭秘 手把手教你设置Nehalem平台
- Computer vision: models, learning and inference 学习笔记1:引言