How to install and use the library of js in npm in ionic.

Asked 2 years ago, Updated 2 years ago, 72 views

Library of Social Shares jsocials

I am trying to use .

npm install jsocials

I installed it in , but I don't know how to use it after this.
The documentation shows how to use jsocials as follows:

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="font-awesome.css"/>
<link rel="stylesheet" type="text/css" href="jssocials.css"/>
<link rel="stylesheet" type="text/css" href="jssocials-theme-flat.css"/>
</head>
<body>
<divid="share"></div>
<script src="jquery.js"></script>
<script src="jsocials.min.js"></script>
<script>
    $("#share").jsSocials({
        shares: ["email", "twitter", "facebook", "googleplus", "linkedin", "pinterest", "stumbleupon", "whatsapp" ]
    });
</script>
</body>
</html>

With ionic, I think you will use the module in the import statement.

import {method name, etc} from 'library name'

I think is the syntax, but if you want to use a library like the one above.
What should I write in the {} of the import statement?

typescript ionic2

2022-09-30 11:45

1 Answers

I don't know the specific story of ionic, but jsocials are not provided as JavaScript modules, so I use them as ambient declarations.
You should also need an additional jquery type definition file.npm install@types/jquery

I think I can use the following jsocials.d.ts at least.

interface JsSocials{
    (arg:any): any;
}

interface JQuery {
    jsSocials —JsSocials;
}


2022-09-30 11:45

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.