demo.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <view class="content">
  3. 常用
  4. 1、延时一定时间进行回调
  5. 2、获取父组件this
  6. 3、节流防抖
  7. 4、对象克隆
  8. 5、路由跳转
  9. 6、对象修改为地址栏传参
  10. 7、常用规则校验
  11. 8、toast消息提示
  12. 9、弹框提示
  13. 10、请求方法
  14. 11、loading
  15. 12、data强制刷新方法
  16. 13、数组添加元素
  17. 14、条件编译
  18. 15、组件传入当前对象
  19. 16、防止点击穿透
  20. 17、数组删除指定元素
  21. 18、缓存
  22. 19、主动刷新滚动数据
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. // 此处为页面级,所以name值可选
  28. name: 'page',
  29. data() {
  30. return {
  31. }
  32. },
  33. onLoad() {
  34. },
  35. mounted() {
  36. // 2、
  37. // 将会得到父页面的this实例
  38. uni.$u.$parent.call(this, 'page')
  39. }
  40. methods: {
  41. demo() {
  42. // 1、
  43. // 300ms后触发回调
  44. uni.$u.sleep(300).then(() => {
  45. console.log('定时结束')
  46. })
  47. // 3、
  48. // <view class="throttle" @tap="$u.throttle(btnAClick, 500)">
  49. // uni.$u.throttle(this.toNext, 500)
  50. // <view class="debounce" @tap="$u.debounce(btnAClick, 500)">
  51. // uni.$u.debounce(this.toNext, 500)
  52. // 4、
  53. let b = uni.$u.deepClone(a);
  54. // 5、
  55. // 无参数
  56. uni.$u.route('/pages/components/empty/index');
  57. // 带参数
  58. uni.$u.route('/pages/goodSource/shippingDetails', {
  59. id: 1,
  60. });
  61. // 6、
  62. uni.$u.queryParams(this.data)
  63. // 7、
  64. uni.$u.test.idCard('110101199003070134')
  65. // 8、
  66. // default/error/success/loading
  67. // <u-toast ref="uToast"></u-toast>
  68. // this.$refs.uToast.show({
  69. // type: 'error',
  70. // message: "最多选择3个地区",
  71. // complete() {
  72. // params.url && uni.navigateTo({
  73. // url: params.url
  74. // })
  75. // }
  76. // })
  77. // uni.$u.toast('倒计时结束后再发送');
  78. // 9、
  79. // <u-modal :show="isShowAlert" :title="alertTitle" :content='alertContent' :closeOnClickOverlay='true' :showCancelButton='true' confirmColor='#2772FB' @confirm="confirmClick" @close="cancelClick" @cancel="cancelClick"></u-modal>
  80. // confirmClick(){
  81. // this.isShowAlert = fasle
  82. // },
  83. // cancelClick(){
  84. // this.isShowAlert = false
  85. // },
  86. // 10、
  87. // this.$request.baseRequest('get', '/commonUser/loginVerifyCode', {
  88. // phone: that.model1.phone,
  89. // verifyCode: that.model1.code
  90. // }).then(res => {
  91. // })
  92. // .catch(res => {
  93. // uni.$u.toast( res.message);
  94. // });
  95. // 11、
  96. // uni.showLoading({
  97. // title: '登录中',
  98. // mask: true
  99. // })
  100. // 12、
  101. // _this.$forceUpdate()
  102. // 13、
  103. // 开头添加 unshift
  104. // 14、
  105. // #ifdef APP-PLUS
  106. // #endif
  107. // 15、$event
  108. // 16、@click.stop
  109. // 17、this.carList.splice(index,1)
  110. // 18、
  111. // uni.setStorageSync('storage_key', 'hello');
  112. // uni.getStorageSync('storage_key');
  113. // 19、
  114. // mescrollInit(mescroll) {
  115. // this.mescroll = mescroll;
  116. // },
  117. // this.mescroll.resetUpScroll()
  118. // this.upCallback({
  119. // size: 10,
  120. // num: 1
  121. // })
  122. }
  123. }
  124. }
  125. </script>