vCards-js
vCards-js copied to clipboard
How can i make it work in vuejs? also in mobile
Please someone upload an implementation
Did you make any progress?
Would be nice to have a Vue and React component. However, for the purposes of Vue you should just be able to use vanilla JavaScript. I know at least one user has done this.
If I were trying to make it work entirely in the browser, I might try to use (with .getFormattedString()
):
https://stackoverflow.com/a/12006048
Except I would use a text/x-vcard
as the mime-type instead of HTML.
A simpler solution woud be:
const download = (vCardString, fileName) => {
let fileURL = window.URL.createObjectURL(new Blob([vCardString]));
let fileLink = document.createElement('a');
fileLink.href = fileURL;
fileLink.setAttribute('download', fileName);
document.body.appendChild(fileLink);
fileLink.click();
};
This should work in any js file. :)
I used it on my NuxtJs code which is built on top of VueJS Just a simple npm install Then on the file Import vcard from 'vcards-js' And it works
Not sure what ur facing
I used it on my NuxtJs code which is built on top of VueJS Just a simple npm install Then on the file Import vcard from 'vcards-js' And it works
Not sure what ur facing
Im doing the same but I dont know how use it in a component, I already import vcard like you
hey, I am using typescript with my code and it won't let me set values to the vCard, so all I'm getting is start and end tag and a bunch of ;;;'s
here's my implementation
<script setup lang="ts">
import vCard from 'vcards-js';
//...
const generate_vCard = () => {
vCard.firstName = 'Rayian';
vCard.lastName = 'Mahi';
console.log(vCard.getFormattedString())
download(vCard.getFormattedString(), 'vcardFile.vcf')
};
The TS error I'm getting is
Property 'firstName' does not exist on type '() => vCard'.ts(2339)
I can only access the attributes when I invoke the vCard function, but that wont let me set new values.
hey, I am using typescript with my code and it won't let me set values to the vCard, so all I'm getting is start and end tag and a bunch of ;;;'s
here's my implementation
<script setup lang="ts"> import vCard from 'vcards-js'; //... const generate_vCard = () => { vCard.firstName = 'Rayian'; vCard.lastName = 'Mahi'; console.log(vCard.getFormattedString()) download(vCard.getFormattedString(), 'vcardFile.vcf') };
The TS error I'm getting is
Property 'firstName' does not exist on type '() => vCard'.ts(2339)
I can only access the attributes when I invoke the vCard function, but that wont let me set new values.
import vCardFactory from 'vcards-js';
const vCard = vCardFactory();
this fixed my issue