<template>
  <div>
    <img @click="shareLink" class="icon" src="/img/icon/share2.png" alt="极度证券">
  </div>
</template>
<script>
import NativeShare from 'nativeshare'
import { copyText } from '@/utils/index'
export default {
  methods: {
    shareLink() {
      try {
        this.nativeShare = new NativeShare()
        var shareData = {
          // title: '极度证券',
          // desc: '极度证券',
          // img: '',
          // 如果是微信该link的域名必须要在微信后台配置的安全域名之内的。
          link: window.location.href,
          icon: window.location.origin + '/logo.png',
        }
        this.nativeShare.setShareData(shareData)
        this.nativeShare.call()
      } catch (err) {
        copyText(window.location.href)
      }
    }
  }
}
</script>
<style lang="less" scoped>
.icon {
  width: 16px;
  display: block;
  cursor: pointer;
}
</style>