美文网首页
SharePoint Framework 在web部件中使用已存

SharePoint Framework 在web部件中使用已存

作者: rewq123 | 来源:发表于2018-07-10 15:42 被阅读5次

博客地址:http://blog.csdn.net/FoxDave

在构建SPFx客户端web部件时,你可以使用公网已有的JavaScript库来构建强大的解决方案。但是在使用的时候你需要考虑你引用的东西没有影响SharePoint页面的性能。

以包的形式引用已存在的库

引用已存在的JavaScript库的通常方式是以包的形式安装到项目中。拿Angular举例,首先在项目中安装它的包:

npm install angular --save

接下来通过TypeScript使用Angular,需要安装类型:

npm install @types/angular --save

最后,在你的web部件中引用Angular,使用import声明:

import { Version } from '@microsoft/sp-core-library';

import {

BaseClientSideWebPart,

IPropertyPaneConfiguration,

PropertyPaneTextField

} from '@microsoft/sp-webpart-base';

import { escape } from '@microsoft/sp-lodash-subset';

import styles from './HelloWorld.module.scss';

import * as strings from 'helloWorldStrings';

import { IHelloWorldWebPartProps } from './IHelloWorldWebPartProps';

import * as angular from 'angular';

export default class HelloWorldWebPart extends BaseClientSideWebPart {

public render(): void {

this.domElement.innerHTML = ``;  angular.module('helloworld', []);  angular.bootstrap(this.domElement, ['helloworld'])

相关文章

网友评论

      本文标题:SharePoint Framework 在web部件中使用已存

      本文链接:https://www.haomeiwen.com/subject/kttqpftx.html