hello
当前位置:   article > 正文

uniapp | 开发中遇到的兼容性问题_uniapp word-break: break-all; 苹果不行

uniapp word-break: break-all; 苹果不行

1、日期格式问题
使用uniapp开发过程中,有这么一段代码,将两个时间字符串通过JS的date构造函数,构造出两个日期并比较大小,在Android平台没有问题,在ios上就出现了日期比较失败,无法执行正常的校验。

ios中不支持-作为日期之间的分隔符,需要使用/。使用replaceAll替换掉日期字符串中的-就好了。

参考文献
进阶之路-前端:ios对new Date() 的兼容问题

2、输入框click事件
禁用状态下载input组件,在android平台可以正常监听click事件,在ios上click监听异常

3、 给placeholder绑定动态变量

<u-input v-model="form.selectDocumentType" class="choiceInput" :placeholder="selectDocumentTypeLabel"/>

4、form表单中关于一条form-item中多个必填项的prop设置

具体解决方法是在中再包裹一层

  1. <u-form-item label="证件类型" prop="selectDocumentType">
  2. <view>
  3. <u-input v-model="form.selectDocumentType" class="choiceInput" :placeholder="selectDocumentTypeLabel"/>
  4. </view>
  5. <view class="typeContainer">
  6. <u-form-item prop="typeNumber">
  7. <u-input v-model="form.typeNumber" class="choiceInput" />
  8. </u-form-item>
  9. </view>
  10. </u-form-item>

5、uview的select组件,数据是对的却一直报Cannot read property ‘children‘ of undefined

是因为children:[]为空,我们可以改成

  1. "children": [
  2. {
  3. "value": null,
  4. "label": ""
  5. }
  6. ]

6、自定义导航栏

在pages.json文件内,将你想要自定义导航栏的内容修改成如下:“navigationStyle”:“custom”

  1. {
  2. "path": "pages/buyProduct/add",
  3. "style": {
  4. "navigationStyle":"custom"
  5. }
  6. }

7、在App.vue页面获取高度

  1. onLaunch: function() {
  2. console.log('App Launch')
  3. uni.getSystemInfo({
  4. success: function(e) {
  5. // #ifndef MP
  6. Vue.prototype.StatusBar = e.statusBarHeight;
  7. if (e.platform == 'android') {
  8. Vue.prototype.CustomBar = e.statusBarHeight + 50;
  9. } else {
  10. Vue.prototype.CustomBar = e.statusBarHeight + 45;
  11. };
  12. // #endif
  13. // #ifdef MP-WEIXIN
  14. Vue.prototype.StatusBar = e.statusBarHeight;
  15. let custom = wx.getMenuButtonBoundingClientRect();
  16. console.log(e.statusBarHeight)
  17. console.log(custom)
  18. Vue.prototype.Custom = custom;
  19. Vue.prototype.CustomBar = (custom.top - e.statusBarHeight)*2 + custom.height;
  20. // #endif
  21. // #ifdef MP-ALIPAY
  22. Vue.prototype.StatusBar = e.statusBarHeight;
  23. Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
  24. // #endif
  25. }
  26. })
  27. initApp();
  28. }

8、uniapp官网示例引入css的方法是错误的

按下面这种写法即可解决

@import '@/common/common.scss';

9、小程序onLaunch和onload先后顺序

10、uniapp 滑太快到底部@scrolltolower没触发,再滑动一下触发2次

11、写position: fixed,在ios下会有兼容性问题

12、uniapp(Vue)修改对象或数据,页面没有相应更改
原因:
Vue 不允许在已经创建的实例上动态添加新的根级响应式属性, Vue 无法探测普通的新增属性

13、关于修改对象

可以使用 Vue.set(object, propertyName, value) 方法向嵌套对象添加响应式 property

  1. Vue.set(vm.someObject, 'b' ,2)
  2. //或者
  3. his.$set(this.someObject, 'b', 2)

14、关于修改数组

可以使用 splice:
vm.items.splice(newLength)

15、微信小程序 CSS border-radius元素 overflow:hidden失效问题 (iPhone ios 苹果兼容)

解决方法:
父元素设置以下两个属性:

backface-visibility: hidden; transform: translate3d(0, 0, 0);

16、小程序页面内含scroll-view时,在scroll-view组件外滑一下页面,会出现1-2秒卡死状态

  1. 方法一、页面设置position:fixed,固定
  2. 方法二、设置整体不能上下滚动
  3. "disableScroll":true, //微信小程序
  4. "mp-alipay": {
  5. "allowsBounceVertical":"NO" //支付宝小程序
  6. }

17、跳转tabBar请用 switchTab(OBJECT),跳转到 tabBar 页面

  • navigateTo:fail can not navigateTo a tabbar page

  1. //正常
  2. uni.switchTab({
  3. url:'/pages/home/home'
  4. })
  5. //报错
  6. // uni.navigateTo({
  7. // url: '/pages/home/home'
  8. // })

18、多层跳转页面路由问题

  1. //一开始是这样写的
  2. uni.navigateTo({
  3. url: '/pages'
  4. })
  5. //改成这样写就OK
  6. uni.redirectTo({
  7. url: '/pages'
  8. })

19.文本在view内自动换行

 word-wrap: break-word;

 word-break: break-all;

  white-space: pre-line;

20. ReferenceError: require is not defined 或者是 切换tabbar报错__call_hook导致页面白屏的时候

解决方式:把之前的代码删掉重新贴一遍就好了,不知道是uniapp还是HB编辑器的问题,就特么很神奇的好了。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/231974?site
推荐阅读
相关标签
  

闽ICP备14008679号