index.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <view class="jnpf-link" :style="textStyle" @click="handleClick()">
  3. <text>{{content}}</text>
  4. </view>
  5. </template>
  6. <script>
  7. export default {
  8. name: 'jnpf-link',
  9. props: {
  10. content: {
  11. type: String,
  12. default: '文本链接'
  13. },
  14. href: {
  15. type: String,
  16. default: ''
  17. },
  18. target: {
  19. type: String,
  20. default: ''
  21. },
  22. textStyle: {
  23. type: Object,
  24. default: {}
  25. }
  26. },
  27. methods: {
  28. handleClick(event) {
  29. if (!this.href) return this.$u.toast("未配置跳转链接")
  30. if (this.target === '_self') {
  31. uni.navigateTo({
  32. url: '/pages/apply/externalLink/index?url=' + this.href,
  33. fail: (err) => {
  34. this.$u.toast("暂无此页面")
  35. }
  36. })
  37. } else {
  38. // #ifdef APP
  39. plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
  40. plus.runtime.openURL(this.href)
  41. })
  42. // #endif
  43. // #ifndef APP
  44. uni.navigateTo({
  45. url: '/pages/apply/externalLink/index?url=' + this.href,
  46. fail: (err) => {
  47. this.$u.toast("暂无此页面")
  48. }
  49. })
  50. // #endif
  51. }
  52. }
  53. }
  54. }
  55. </script>
  56. <style lang="scss" scoped>
  57. .jnpf-link {
  58. width: 100%;
  59. color: #1890ff;
  60. text-align: right;
  61. }
  62. </style>