Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can i make it work in vuejs? also in mobile #39

Open
fabriguespe opened this issue May 4, 2019 · 7 comments
Open

How can i make it work in vuejs? also in mobile #39

fabriguespe opened this issue May 4, 2019 · 7 comments

Comments

@fabriguespe
Copy link

Please someone upload an implementation

@pynner
Copy link

pynner commented May 9, 2019

Did you make any progress?

@enesser
Copy link
Owner

enesser commented May 9, 2019

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.

@Imperio8
Copy link

Imperio8 commented May 10, 2021

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. :)

@mo9a7i
Copy link

mo9a7i commented May 16, 2021

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

@carlosaroca
Copy link

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

@xrayian
Copy link

xrayian commented Aug 7, 2022

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.

@xrayian
Copy link

xrayian commented Aug 8, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants