1.0.3 • Published 5 years ago

vue-navigator-share v1.0.3

Weekly downloads
50
License
MIT
Repository
github
Last release
5 years ago

vue-navigator-share

A Vue component to use native sharing mechanism of the device as part of the Web Share API.

Support only https and mobile browser Demo

Instalation

$ npm install --save vue-navigator-share

Properties

proptypedescriptionrequired
on-errorFunctioncallback on errorfalse
on-successFunctioncallback on successfalse
urlStringurl to sharetrue
titleStringtitle to sharefalse
textStringtext to sharefalse

Usage

<navigator-share
  v-bind:on-error="function"
  v-bind:on-success="otherFunction"
  url="url_to_share"
  title="title_to_share"
  text="text_to_share"
></navigator-share>
<script>
import NavigatorShare from 'vue-navigator-share'

export default {
  name: 'app',
  data () {
    return {
    }
  },
  components: {
    NavigatorShare
  },
  methods: {
  }
}
</script>

Example

<navigator-share
  v-bind:on-error="onError"
  v-bind:on-success="onSuccess"
  v-bind:url="url"
  v-bind:title="title"
  text="Hello World"
></navigator-share>
<script>
import NavigatorShare from 'vue-navigator-share'

export default {
  name: 'app',
  data () {
    return {
    }
  },
  components: {
    NavigatorShare
  },
  computed: {
    url() {
      return window.location.href;
    },
    title() {
      return document.title;
    }
  },
  methods: {
    onError(err) {
      alert(err);
      console.log(err);
    },
    onSuccess(err) {
      console.log(err);
    }
  }
}
</script>