安装 Node v10.16.1 并安装 gulp 和 yo(一切看起来都不错!)后,它在命令时失败,yo @microsoft/sharepoint 出现 TypeError:lookups.flatMap is not a function
C:\Users\MYNAME\AppData\Roaming\npm\node_modules\yo\node_modules\yeoman-environment\lib\resolver.js:70
filePatterns: lookups.flatMap(prefix => [`${prefix}/*/index.ts`, `${prefix}/*/index.js`]),
^
TypeError: lookups.flatMap is not a function
at Environment.resolver.lookup (C:\Users\MYNAME\AppData\Roaming\npm\node_modules\yo\node_modules\yeoman-environment\lib\resolver.js:70:27)
at init (C:\Users\MYNAME\AppData\Roaming\npm\node_modules\yo\lib\cli.js:130:7)
at pre (C:\Users\MYNAME\AppData\Roaming\npm\node_modules\yo\lib\cli.js:89:3)
at Object.<anonymous> (C:\Users\MYNAME\AppData\Roaming\npm\node_modules\yo\lib\cli.js:219:3)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
Run Code Online (Sandbox Code Playgroud)
我是初学者!几天前它起作用了,然后我安装了 nvm(按照微软的指令将节点 v8 交换到节点 v10)然后问题开始了,我卸载了 nvm、节点 v8 和 v10,然后重新安装了节点 v10。TypeError 返回。也许与路径有关?
任何的想法 ?谢谢
我已经创建了一个可配置的选项卡应用程序并将其加载到团队中.在内容页面上,我想允许用户下载文件.只是链接到该文件不起作用.当用户单击该链接时,内容iframe会重定向并变为空白.我已经在teams.microsoft.com的团队的Web应用程序版本中对此进行了测试,它运行正常.该文件会按预期下载.
如果它有所不同,则使用SPFx在现代页面上将内容页面托管在SharePoint中.
所以我有这个反应组件,它的下拉属性(SPFx)有2个值,我需要当下拉列表更改时再次重新渲染反应,下拉列表定义从中检索值的数据源。
Webpart.ts
import * as React from 'react';
import * as ReactDom from 'react-dom';
import { Version } from '@microsoft/sp-core-library';
import {
BaseClientSideWebPart,
IPropertyPaneConfiguration,
PropertyPaneDropdown
} from "@microsoft/sp-webpart-base";
import * as strings from 'AbstractfactoryWebPartStrings';
import Abstractfactory from './components/Abstractfactory';
import { IAbstractFactoryProps } from './components/IAbstractFactoryProps';
import { IAbstractfactoryWebPartProps } from "./IAbstractfactoryWebPartProps";
export default class AbstractfactoryWebPart extends BaseClientSideWebPart<IAbstractfactoryWebPartProps> {
public render(): void {
const element: React.ReactElement<IAbstractFactoryProps > = React.createElement(
Abstractfactory,
{
datasource: this.properties.datasource
}
);
ReactDom.render(element, this.domElement);
}
protected get dataVersion(): Version …Run Code Online (Sandbox Code Playgroud) 我正在尝试构建一个 spfx web 部件,在同一上下文中更新列表,\n该按钮触发一个函数,该函数从上下文中获取当前用户名和日期,构建一个 json,然后将其字符串化,然后构建一个图形请求并将其与一个事件放在一起onclick。
我收到以下错误:
\n\n\n类型“Promise”不可分配给类型\n“MouseEventHandler”。类型 'Promise'\n 与签名 '(event:\nMouseEvent<HTMLButtonElement, MouseEvent>): void'.ts(2322)\nindex.d.ts(1449, 9): 预期类型来自属性 ' 不匹配onClick'\n这是在类型上声明的\n'DetailedHTMLProps<ButtonHTMLAttributes
\n
签名WP.tsx:
\nimport * as React from 'react';\nimport * as strings from 'SignatureWpWebPartStrings';\nimport styles from './SignatureWp.module.scss';\nimport { ISignatureWpProps, ISignatureWpState, SharepointListItem} from './ISignatureWpProps';\nimport { escape } from '@microsoft/sp-lodash-subset';\nimport { Checkbox } from 'office-ui-fabric-react';\nimport { ServiceKey, ServiceScope } from "@microsoft/sp-core-library";\nimport { PageContext } from "@microsoft/sp-page-context";\nimport * as moment from 'moment';\nimport { WebPartContext } from "@microsoft/sp-webpart-base";\nimport { ClientMode } from …Run Code Online (Sandbox Code Playgroud) 从文档中,我找不到任何方法来获取我放置webpart的网站的siteId.
例如,
我当前的网站是:https://{hostname}/sites/main1< - 不是root网站,但我想获得这个siteId
我在这里测试我的webpart: https://{hostname}/sites/main1/_layouts/15/workbench.aspx
我怎样才能做到这一点?从文档中,
站点是唯一标识符,它是以下值的组合ID:
网站集主机名(contoso.sharepoint.com)
网站集唯一ID(guid)
网站唯一ID(guid)
我可以通过使用location.hostname(是的,我使用JavaScript + React构建我的webpart)轻松获取主机名,但是如何使用Graph API轻松获取site-id?
因此,我正在构建一个 spfx Web 部件,其中一项功能是显示链接预览。我使用这个库来完成这项任务。我必须更改包“styled-components”的版本并更新我的“react”(16.4.18)和“react-dom”(16.0.9)才能使其工作。进行这些更改并运行后,gulp build我收到以下错误列表:
[10:21:13] [tsc] typescript version: 2.4.2
[10:21:17] Error - [tsc] node_modules/@types/prop-types/index.d.ts(27,38): error TS1005: '=' expected.
[10:21:17] Error - [tsc] node_modules/@types/prop-types/index.d.ts(29,46): error TS1005: ';' expected.
[10:21:17] Error - [tsc] node_modules/@types/prop-types/index.d.ts(29,75): error TS1005: ';' expected.
[10:21:17] Error - [tsc] node_modules/@types/prop-types/index.d.ts(29,99): error TS1005: ';' expected.
[10:21:17] Error - [tsc] node_modules/@types/prop-types/index.d.ts(31,54): error TS1005: ';' expected.
[10:21:17] Error - [tsc] node_modules/@types/prop-types/index.d.ts(31,78): error TS1005: ';' expected.
[10:21:17] Error - [tsc] node_modules/@types/prop-types/index.d.ts(31,81): error TS1109: Expression expected.
[10:21:17] Error - …Run Code Online (Sandbox Code Playgroud) 我在 spfx react 应用程序中使用 socket.io.client 并在进行套接字连接时收到此错误:
Uncaught TypeError: Cannot read property 'sid' of undefined
Run Code Online (Sandbox Code Playgroud) 我正在尝试构建一个包含ChoiceGroup的SPFx Webpart。当我将CSS样式设置为垂直对齐时:ms-sm12
Show assigned to:
o anyone
* me
o nobody
Run Code Online (Sandbox Code Playgroud)
我喜欢它们在一行中水平对齐:
Show assigned to: o anyone * me o nobody
Run Code Online (Sandbox Code Playgroud)
当我将样式设置ms-sm6为时,它会将它们“混合”对齐:将Slider和Toggle设置为ms-sm3
Show assigned to: o anyone
* me
o nobody
Run Code Online (Sandbox Code Playgroud)
有了ms-sm4它看起来像:
使用ms-sm3,时ms-sm2,ms-sm1看起来(标题越来越紧,并且所有选项都在一个列中:
如何强制/鼓励将选项水平呈现?
我正在尝试创建一个全天活动:
let foobar: any = {
"subject": calendarEvent.Title+"v5",
"body": {
"contentType": "HTML",
"content": calendarEvent! || !calendarEvent.Description ? "No Description": calendarEvent.Description,
},
"start": {
"dateTime": calendarEvent.EventDate,
"timeZone": moment.tz.guess(),
},
"end": {
"dateTime": calendarEvent.EndDate,
"timeZone": moment.tz.guess(),
},
"location": {
"displayName": !calendarEvent || !calendarEvent.Location ? "No Location": calendarEvent.Location,
},
"isAllDay": !calendarEvent || !calendarEvent.fAllDayEvent ? false : true,
};
context.msGraphClientFactory.getClient()
.then((client: MSGraphClient) => {
client.api("/me/calendar/events").post(foobar)
.then((content: any) => {
console.log("CalendarService | createCalendarEvent | content: ", content);
});
});
Run Code Online (Sandbox Code Playgroud)
日志:
当我包含“isAllDay”属性时,它会失败并返回 400(错误请求)。
我排除了该属性,它正在创建没有问题的事件。
有什么建议么?
编辑: …
在我们的 SPFx SharePoint 在线 Web 部件中,我们的 javascript 文件中有以下代码:-
spservices.prototype.getLookupFieldOptions = function (siteUrl, listId, fieldInternalName) {
return __awaiter(this, void 0, void 0, function () {
var fieldOptions, web, results, options, _i, options_1, option, error_14;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
fieldOptions = [];
_a.label = 1;
case 1:
_a.trys.push([1, 5, , 6]);
web = new Web(siteUrl);
return [4 /*yield*/, web.lists.getById(listId)
.fields.usingCaching()
.filter("InternalName eq '" + fieldInternalName + "'")
.select("LookupList", "LookupWebId", "LookupField")
.top(1)
.get()];
case 2:
results = …Run Code Online (Sandbox Code Playgroud) spfx ×10
reactjs ×3
typescript ×3
javascript ×2
sharepoint ×2
css ×1
download ×1
file ×1
gulp ×1
node.js ×1
office-js ×1
socket.io ×1
spservices ×1
yeoman ×1