mock.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <template>
  2. <view class="container">
  3. <u-navbar :is-fixed="false" :border-bottom="false" :is-back="true" back-icon-name="arrow-leftward"
  4. back-icon-color="#fff" back-icon-size="35" :background="{ background: 'linear-gradient(90deg, #69b0ff, #5f88ff)' }" title="Mock 调用"
  5. title-color="#fff">
  6. </u-navbar>
  7. <view class="u-demo">
  8. <view class="u-demo-wrap">
  9. <view class="u-demo-title">演示效果</view>
  10. <view class="u-demo-area u-flex u-row-center">
  11. 数据为:{{data}}
  12. </view>
  13. </view>
  14. <view class="u-config-wrap">
  15. <view class="u-config-title u-border-bottom">参数操作</view>
  16. <view class="u-config-item">
  17. <view class="u-item-title">按钮点击</view>
  18. <u-button @click="doRequest">获取数据</u-button>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import {
  26. fakeBannerList
  27. } from "@/api/mock/home.js";
  28. export default {
  29. data() {
  30. return {
  31. data: {}
  32. };
  33. },
  34. methods: {
  35. doRequest() {
  36. let keyword = "";
  37. fakeBannerList().then(data => {
  38. this.data = data;
  39. this.$u.func.showToast({
  40. title: '数据获取成功',
  41. })
  42. }).catch(() => {
  43. })
  44. }
  45. },
  46. }
  47. </script>