爱简收旧衣按件回收前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
2.4 KiB

1 week ago
  1. <template>
  2. <text class="u-link" @tap.stop="openLink" :style="{
  3. color: color,
  4. fontSize: fontSize + 'rpx',
  5. borderBottom: underLine ? `1px solid ${lineColor ? lineColor : color}` : 'none',
  6. paddingBottom: underLine ? '0rpx' : '0'
  7. }">
  8. <slot>
  9. {{ text }}
  10. </slot>
  11. </text>
  12. </template>
  13. <script>
  14. /**
  15. * link 超链接
  16. * @description 该组件为超链接组件在不同平台有不同表现形式在APP平台会通过plus环境打开内置浏览器在小程序中把链接复制到粘贴板同时提示信息在H5中通过window.open打开链接
  17. * @tutorial https://www.uviewui.com/components/link.html
  18. * @property {String} text 文字内容
  19. * @property {String} color 文字颜色默认#606266
  20. * @property {String Number} font-size 字体大小单位rpx默认28
  21. * @property {Boolean} under-line 是否显示下划线默认false
  22. * @property {String} href 跳转的链接要带上http(s)
  23. * @property {String} line-color 下划线颜色默认同color参数颜色
  24. * @property {String} mp-tips 各个小程序平台把链接复制到粘贴板后的提示语默认链接已复制请在浏览器打开
  25. * @example <u-link href="http://www.uviewui.com">蜀道难难于上青天</u-link>
  26. */
  27. export default {
  28. name: "u-link",
  29. props: {
  30. // 文本内容
  31. text: {
  32. type: String,
  33. default: ''
  34. },
  35. // 文字颜色
  36. color: {
  37. type: String,
  38. default: '#2979ff'
  39. },
  40. // 字体大小,单位rpx
  41. fontSize: {
  42. type: [String, Number],
  43. default: 28
  44. },
  45. // 是否显示下划线
  46. underLine: {
  47. type: Boolean,
  48. default: false
  49. },
  50. // 要跳转的链接
  51. href: {
  52. type: String,
  53. default: ''
  54. },
  55. // 小程序中复制到粘贴板的提示语
  56. mpTips: {
  57. type: String,
  58. default: '链接已复制,请在浏览器打开'
  59. },
  60. // 下划线颜色
  61. lineColor: {
  62. type: String,
  63. default: ''
  64. }
  65. },
  66. methods: {
  67. openLink() {
  68. // #ifdef APP-PLUS
  69. plus.runtime.openURL(this.href)
  70. // #endif
  71. // #ifdef H5
  72. window.open(this.href)
  73. // #endif
  74. // #ifdef MP
  75. uni.setClipboardData({
  76. data: this.href,
  77. success: () => {
  78. uni.hideToast();
  79. this.$nextTick(() => {
  80. this.$u.toast(this.mpTips);
  81. })
  82. }
  83. });
  84. // #endif
  85. }
  86. }
  87. }
  88. </script>
  89. <style lang="scss" scoped>
  90. @import "../../libs/css/style.components.scss";
  91. .u-link {
  92. line-height: 1;
  93. }
  94. </style>