import * as React from 'react';
import styles from './Birthday.module.scss';
import { IBirthdayProps } from './IBirthdayProps';
import { Icon } from 'office-ui-fabric-react/lib/Icon';
import { initializeIcons } from '@uifabric/icons';
initializeIcons();
import Slider from 'react-slick';
export default class Birthday extends React.Component<IBirthdayProps, {}> {
public next() {
this.slider.slickNext();
}
public previous() {
this.slider.slickPrev();
}
public render(): React.ReactElement<IBirthdayProps> {
const settings = {
dots: true,
infinite: true,
rows: 2,
slidesPerRow: 2,
slidesToShow: 1,
speed: 500,
appendDots: dots => (
<div
style={{
backgroundColor: '#ddd',
padding: …Run Code Online (Sandbox Code Playgroud)我正在office-ui-fabric-react中寻找一个Table组件,我可以在自定义 WebPart中使用它来显示来自 API 的一些数据,并且如果用户愿意,可以轻松将其导出到 Excel 工作表。
我在这里没有看到任何表格实现,这对我来说很奇怪,因为根据我的理解,Office UI Fabric 有点像“像在 Microsoft Office 中编辑一样编辑您的网站”,并且 Microsoft Office 有一个表格:
https://developer.microsoft.com/en-us/fabric#/controls/web
我发现了这个例子,它使用简单的 HTML 元素来创建一个表格,但是经过一段时间的研究后,Fabric JS 与 Fabric React 并不相同,我们使用的是后者:
https://developer.microsoft.com/en-us/fabric-js/components/table/table
经过更多挖掘后,我实际上在 office-ui-fabric-react 中找到了这个表:
但是我无法像这样导入它:
import { Table } from "office-ui-fabric-react"
经过进一步挖掘,我在同一个 Github 存储库中找到了这个示例站点:
它使用表,并像这样导入它:
import { Table } from '@uifabric/example-app-base/lib/index2';
然后我就可以安装这个 npm 包并使用其中的 Table:
https://www.npmjs.com/package/@uifabric/example-app-base
然而,其中有一个免责声明:“这些组件主要用于在 office-ui-fabric-react 存储库中使用。因此,API 可能不稳定。”
所以我不确定这是否是解决此问题的最佳方法,而且我也没有看到任何 Excel 导出功能。
我正在尝试学习如何使用 SPFx,但是在跑步的第一步中我就失败了yo @microsoft/sharepoint。
运行时出现以下错误yo @microsoft/sharepoint:
Error @microsoft/sharepoint\n\nYou don't seem to have a generator with the name \xe2\x80\x9c@microsoft/sharepoint\xe2\x80\x9d installed.\nBut help is on the way:\n\nYou can see available generators via npm search yeoman-generator or via http://yeoman.io/generators/.\nInstall them with npm install @microsoft/generator-sharepoint.\n\nTo see all your installed generators run yo --generators. Adding the --help option will also show subgenerators.\n\nIf yo cannot find the generator, run yo doctor to troubleshoot your system.\nRun Code Online (Sandbox Code Playgroud)\n我尝试过运行npm install @microsoft/generator-sharepoint -g,但这并不能解决上述错误。还值得注意的是,我在运行安装生成器命令时遇到了一堆错误: …
行是动态绘制的,还有删除每行的按钮。
<span className="ms-Table-cell">
<div>
<IconButton
onClick= { this._removeItemFromDetail }
id={ detail.Id.toString() }
iconProps={ { iconName: 'Cancel' } }
title='Delete' />
</div>
</span>
private _removeItemFromDetail(e) {
console.log("e.target",e.target);
}
Run Code Online (Sandbox Code Playgroud)
问题是,每次我在控制台中单击删除按钮时,都会向我显示:
因此,我无法访问Button Id属性,但这仅在发布Webpart时发生。有谁知道如何解决?
谢谢!
我正在尝试在 spfx webpart 中使用 SPHttpClient 上传文件。
我正在尝试的代码是
const spOpts:ISPHttpClientOptions={body: { my: "bodyJson" } };
contextDetails.spHttpClient.post(url,SPHttpClient.configurations.v1, spOpts)
.then(response => {
return response;
})
.then(json => {
return json;
}) as Promise<any>
Run Code Online (Sandbox Code Playgroud)
但我不确定如何将文件内容添加到这个 httpClient API。
我想我们必须在 body 参数中将文件内容添加到 spOpts 中。我不确定。
任何帮助表示赞赏。谢谢。
我正在使用 SPFX 创建一个简单的 SharePoint webpart,我想在解决方案中引用图像。我用了这个方法:
require("@microsoft/loader-set-webpack-public-path!");
<img src="${require<string>('../../assets/logo.jpg')}" alt="My Company" />
Run Code Online (Sandbox Code Playgroud)
但它不起作用。
如何做到这一点?
我正在使用带有 react.js 的 spfx 创建一个 web 部件。我创建了一个新组件,在导入这个新创建的组件时,我收到“模块没有导出成员”的消息。如何解决这个问题?
import Form from 'react-validation/build/form';
import Input from 'react-validation/build/input';
import Button from 'react-validation/build/input';
import * as React from 'react';
import validator from 'validator';
const required = (value) => {
if (!value.toString().trim().length) {
// We can return string or jsx as the 'error' prop for the validated
Component
return 'require';
}
};
const email = (value) => {
if (!validator.isEmail(value)) {
return `${value} is not a valid email.`
}
};
export default class NewForm extends …Run Code Online (Sandbox Code Playgroud) 我有多个 id 但有不同问题答案的 Responses 数组。
Responses =
[0:{Id : 1,Name : John, QuestionId :1,Answer :8},
1:{Id : 1,Name : John, QuestionId :2,Answer :9},
2:{Id : 1,Name : John, QuestionId :3,Answer :3},
3:{Id : 1,Name : John, QuestionId :4,Answer :2},
4:{Id : 2,Name : Mark, QuestionId :1,Answer :6},
5:{Id : 2,Name : Mark, QuestionId :2,Answer :2},
6:{Id : 2,Name : Mark, QuestionId :3,Answer :5},
7:{Id : 2,Name : Mark, QuestionId :4,Answer :1}]
----------------------------------------------------------------
Output I want :
Arr =
[0:{Id : …Run Code Online (Sandbox Code Playgroud) spfx ×8
sharepoint ×4
reactjs ×2
typescript ×2
arrays ×1
button ×1
html ×1
httpclient ×1
java ×1
javascript ×1
jquery ×1
slick.js ×1
yeoman ×1