After create an sample spfx webpart with "nojavascript"
1. In visual studio code, open config.json file in your machine (press ctrl+p and type config.json file).
2. external object key shows empty initially.
3. Open Node JS cmd prompt and install requried external library files using npm
To Install Jquery: npm install jquery@2
Install Jquery types for typescript handy: npm install @types/jquery@2
Under externals key object provide below reference
1. In visual studio code, open config.json file in your machine (press ctrl+p and type config.json file).
2. external object key shows empty initially.
3. Open Node JS cmd prompt and install requried external library files using npm
To Install Jquery: npm install jquery@2
Install Jquery types for typescript handy: npm install @types/jquery@2
Jquery UI
npm install jqueryui
npm install
@types/jqueryui
Bootstrap
npm install
bootstrap
Angular:
npm
install @types/angular --save-dev
"externals": {
"jquery":"node_modules/jquery/dist/jquery.min.js",
"angular": {
"path": "https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.6/angular.min.js",
"globalName": "angular"
},
"bootstrap": {
"path": "https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js",
"globalName": "bootstrap",
"globalDependencies": ["jquery"]
}
},
In your webpart ts file, refer the files as below
import { SPComponentLoader } from '@microsoft/sp-loader';
let cssURL = "https://mercedessaga.sharepoint.com/sites/myfirstappcatalog/SiteAssets/bootstrap.min.css";
SPComponentLoader.loadCss(cssURL);
let cssURLIcon = "https://mercedessaga.sharepoint.com/sites/teja_dev/SiteAssets/CSS/font-awesome.css";
SPComponentLoader.loadCss(cssURLIcon);
SPComponentLoader.loadScript('https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js', { globalExportsName: 'jQuery' }).then((jQuery: any): void => {
SPComponentLoader.loadScript('https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js', { globalExportsName: 'jQuery' }).then((): void => {
});
Comments
Post a Comment