UNIAPP+uview2开发小程序填坑

[ 2023-10-06 09:20:11 | 作者: admin ]
字号: | |
1.快捷提示toast
this.$u.toast('手机号码填写有误,请重新填写');

2.快捷请求代码
this.$http.post('api接口地址', {
  encryptedData: telObj,
  iv: ivObj
  }).then(myres => {
console.log("请求信息: ",myres);
  }).catch(errres => {
  })      

3.customStyle,一般作用于组件内部的根节点,可以方便设置一些基础样式,它同时能接受对象或者字符串的样式形式
// 对象形式(强烈建议对象的写法)
<u-badge :customStyle="{backgroundColor: 'red'}"></u-badge>


// 字符串形式
<u-badge customStyle="background-color: red;"></u-badge>


4.判断token 有效结果的时候可以用try cache。
如果不主动捕获错误可能导致token已经过期,但是接口任然用当前的结果去发起请求。
try{
     var id = uni.getStorageSync('id');
     var name = uni.getStorageSync('name');
   }catch(e){
     //TODO handle the exception
   }
评论Feed 评论Feed: http://blog.xg98.com/feed.asp?q=comment&id=2941

这篇日志没有评论。

此日志不可发表评论。