routeItem.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <view
  3. class="routeItem"
  4. @click.stop="showMenu"
  5. >
  6. <view>
  7. <text class="routeText">{{ item.path }}</text>
  8. </view>
  9. </view>
  10. </template>
  11. <script>
  12. export default {
  13. props: {
  14. item: {
  15. type: Object,
  16. default: () => ({}),
  17. },
  18. },
  19. data() {
  20. return {};
  21. },
  22. methods: {
  23. /**
  24. * 展示菜单
  25. */
  26. showMenu() {
  27. let that = this;
  28. let menuList = [];
  29. let p = that.item.path.substr(0, 20);
  30. if (p.length == 20) {
  31. p = p + "...";
  32. }
  33. menuList.push(`复制路径(${p})`);
  34. let isTabBar = false;
  35. if (that.item.meta && that.item.meta.isTabBar) {
  36. isTabBar = true;
  37. }
  38. if (!isTabBar) {
  39. menuList.push("跳转至此页面");
  40. }
  41. uni.showActionSheet({
  42. itemList: menuList,
  43. success({ tapIndex }) {
  44. if (tapIndex == 0) {
  45. uni.setClipboardData({
  46. data: that.item.path,
  47. });
  48. } else {
  49. uni.$emit("devTools_showRouteDialog", that.item.path);
  50. }
  51. },
  52. });
  53. },
  54. },
  55. };
  56. </script>
  57. <style lang="scss" scoped>
  58. .routeItem {
  59. padding: 10rpx 20rpx;
  60. border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  61. display: flex;
  62. flex-direction: column;
  63. .routeText {
  64. width: 710rpx;
  65. font-size: 20rpx;
  66. line-height: 26rpx;
  67. color: #333;
  68. }
  69. }
  70. .routeItem:active {
  71. background-color: rgba(0, 0, 0, 0.05);
  72. }
  73. </style>