demo.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. 20、helper
  24. </view>
  25. </template>
  26. <script>
  27. export default {
  28. // 此处为页面级,所以name值可选
  29. name: 'page',
  30. data() {
  31. return {
  32. }
  33. },
  34. onLoad() {
  35. },
  36. mounted() {
  37. // 2、
  38. // 将会得到父页面的this实例
  39. uni.$u.$parent.call(this, 'page')
  40. }
  41. methods: {
  42. demo() {
  43. // 1、
  44. // 300ms后触发回调
  45. uni.$u.sleep(300).then(() => {
  46. console.log('定时结束')
  47. })
  48. // 3、
  49. // <view class="throttle" @tap="$u.throttle(btnAClick, 500)">
  50. // uni.$u.throttle(this.toNext, 500)
  51. // <view class="debounce" @tap="$u.debounce(btnAClick, 500)">
  52. // uni.$u.debounce(this.toNext, 500)
  53. // 4、
  54. let b = uni.$u.deepClone(a);
  55. // 5、
  56. // 无参数
  57. uni.$u.route('/pages/components/empty/index');
  58. // 带参数
  59. uni.$u.route('/pages/goodSource/shippingDetails', {
  60. id: 1,
  61. });
  62. // 6、
  63. uni.$u.queryParams(this.data)
  64. // 7、
  65. uni.$u.test.idCard('110101199003070134')
  66. // 8、
  67. // default/error/success/loading
  68. // <u-toast ref="uToast"></u-toast>
  69. // this.$refs.uToast.show({
  70. // type: 'error',
  71. // message: "最多选择3个地区",
  72. // complete() {
  73. // params.url && uni.navigateTo({
  74. // url: params.url
  75. // })
  76. // }
  77. // })
  78. // uni.$u.toast('倒计时结束后再发送');
  79. // 9、
  80. // <u-modal :show="isShowAlert" :title="alertTitle" :content='alertContent' :closeOnClickOverlay='true' :showCancelButton='true' confirmColor='#2772FB' @confirm="confirmClick" @close="cancelClick" @cancel="cancelClick"></u-modal>
  81. // confirmClick(){
  82. // this.isShowAlert = fasle
  83. // },
  84. // cancelClick(){
  85. // this.isShowAlert = false
  86. // },
  87. // 10、
  88. // this.$request.baseRequest('get', '/commonUser/loginVerifyCode', {
  89. // phone: that.model1.phone,
  90. // verifyCode: that.model1.code
  91. // }).then(res => {
  92. // })
  93. // .catch(res => {
  94. // uni.$u.toast( res.message);
  95. // });
  96. // 11、
  97. // uni.showLoading({
  98. // title: '登录中',
  99. // mask: true
  100. // })
  101. // 12、
  102. // _this.$forceUpdate()
  103. // 13、
  104. // 开头添加 unshift
  105. // 14、
  106. // #ifdef APP-PLUS
  107. // #endif
  108. // 15、$event
  109. // 16、@click.stop
  110. // 17、this.carList.splice(index,1)
  111. // 18、
  112. // uni.setStorageSync('storage_key', 'hello');
  113. // uni.getStorageSync('storage_key');
  114. // 19、
  115. // mescrollInit(mescroll) {
  116. // this.mescroll = mescroll;
  117. // },
  118. // this.mescroll.resetUpScroll()
  119. // this.upCallback({
  120. // size: 10,
  121. // num: 1
  122. // })
  123. // 20、
  124. // import helper from '@/common/helper.js';
  125. }
  126. }
  127. }
  128. </script>