npm outdated --global
npm update -g @microsoft/generator-sharepoint
md spfx-ms-teams-personal-app
cd spfx-ms-teams-personal-app
yo @microsoft/sharepoint
npm shrinkwrap
code
.
{
"$schema"
:
"https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json"
,
"id"
"0648ced7-f57d-40f3-b9ed-b4152d877b52"
"alias"
"MyTeamsPersonalAppWebPart"
"componentType"
"WebPart"
// The "*" signifies that the version should be taken from the package.json
"version"
"*"
"manifestVersion"
: 2,
// If true, the component can only be installed on sites where Custom Script is allowed.
// Components that allow authors to embed arbitrary script code should set this to true.
// https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f
"requiresCustomScript"
false
"supportedHosts"
: [
"SharePointWebPart"
"TeamsPersonalApp"
],
"preconfiguredEntries"
: [{
"groupId"
"5c03119e-3074-46fd-976b-c60198311f70"
// Other
"group"
: {
"default"
"Other"
},
"title"
"MyTeamsPersonalApp"
"description"
"MyTeamsPersonalApp description"
"officeFabricIconFontName"
"Page"
"properties"
}
}]
public
render():
void
let title:
string
=
''
;
let subTitle:
let siteTabTitle:
if
(
this
.context.sdks.microsoftTeams) {
// We have teams context for the web part
title =
"Welcome to Teams!"
subTitle =
"Building custom enterprise tabs for your business."
siteTabTitle =
"We are in the context of following Team: "
+
.context.sdks.microsoftTeams.context.teamName;
else
// We are rendered in normal SharePoint context
"Welcome to SharePoint!"
"Customize SharePoint experiences using Web Parts."
"We are in the context of following site: "
.context.pageContext.web.title;
.domElement.innerHTML = `
<div
class
"${ styles.myTeamsPersonalApp}"
>
"${ styles.container}"
"${ styles.row}"
"${ styles.column}"
<span
"${ styles.title}"
>${title}</span>
<p
"${ styles.subTitle}"
>${subTitle}</p>
"${ styles.description}"
>${siteTabTitle}</p>
>Description property value - ${escape(
.properties.description)}</p>
<a href=
"https://aka.ms/spfx"
"${ styles.button}"
"${ styles.label}"
>Learn more</span>
</a>
</div>
</div>`;
gulp bundle --ship
gulp package-solution --ship