React 报错Super expression must either be null or a function, not undefined
问题描述在定义class组件的时候出现:Super expression must either be null or a function, not undefined报错!
解决问题原来是React.component中的component首字母没有大写!!!
将React.component改写成React.Component 问题解决。
12345678910111213141516171819class Message extends React.Component { constructor(props) { super(props); this.state = { messageList: props.messageList }; } render() { return ( <div> {this.state.messageList.length > 0 ? ( <h2>You have {this ...
uniapp 阿里云oss图片上传封装多平台适用
第一步:辅助函数;123456789101112131415161718// 添加文件名后缀方法,例如 .pngfunction getSuffix(filename) { let pos = filename.lastIndexOf('.'); let suffix = ''; if (pos != -1) { suffix = filename.substring(pos); } return suffix;}// 自定义文件夹(file)function getFileName(file, filename) { return ( file + Math.random() .toString(36) .substring(3, 20) + new Date().getTime() + getSuffix(filename) );}
第二步:暴露出的图片上传函数;12345678910111213141516171819// 选择上传图片export function u ...
JS 常用字符串方法、数值方法、数组方法总汇
JavaScript 字符串方法length 属性返回字符串的长度
12let str = "shaoin";console.log(str.length) // 6
split() 方法将字符串转换为数组
123let str = "shaoin";console.log(str.split('ao')) // ["sh", "in"]console.log(str.split('')) // ["s", "h", "a", "o", "i", "n"]
search() 方法该方法设置一个参数:需要搜索的字符串。
搜索特定的字符串,并返回位置
123let str = "shaoin";console.log(str.search('ao')) // 2console.log(str.search(& ...
uniapp 解决switchTab跳转tab页面不能直接传参问题
问题描述在使用uniapp 中uni.switchTab跳转到相应的 tabbar 页面后,无法读取到需要传递过来的参数。目前没有很好的直接传递参数的方法(2021年8月)。
问题分析tabbar 页面在加载完成后,不会在切换和跳转中被销毁。也就是意味着跳转到已经加载过了的tabbar页面后,onLoad 中的代码是不会去执行。好在onShow、onHide 中的代码在切换、展现、隐藏执行。
解决问题
利用uni.reLaunch()关闭所有页面,打开到应用内的某个页面。
123456789// 跳转页面uni.reLaunch({ url:'pages/home/index?id=123&val=reLaunch'});// tabbar 页面onLoad(option){ console.log(option); // {id: 123, val: reLaunch}}
利用uni.setStorageSync本地缓存需要传递的参数,在跳转到tabbar 页面后用onShow 和 un ...
uniapp IOS数字键盘没有小数点
问题描述当IOS手机用户在输入金额或其它数字,要用到小数点的时候,发现可操作的键盘只有数字,没有小数点等其它符号。
解决方案根据描述,我们从input 标签的 type 属性入手。当type的属性值为number的时候。如:下左图显示;
1<input type="number" placeholder="请输入" />
图1 无小数点
图2 有小数点
当type的属性值为digit的时候。如:上右图显示;
1<input type="digit" placeholder="请输入" />
问题总结根据 uniapp 官网提供type具体属性和功能如下:
值
说明
平台差异说明
text
文本输入键盘
number
数字输入键盘
均支持,App平台、H5平台 3.1.22 以下版本 vue 页面在 iOS 平台显示的键盘包含负数和小数。
idcard
身份证输入键盘
微信、支付宝、百度、QQ小程序
...