我想知道如何为我的SPFx解决方案(网页部分)创建附件组件,但不能弄清楚。
我已经制作了这样的TextField组件-〉
import * as React from 'react';
import * as PropTypes from 'prop-types';
import { TextField } from 'office-ui-fabric-react';
const TextFieldInput = ({props, otherProps = null, onValueChange}) =>{
const handleChange = (event: any) => {
if(props.returnEvent){
onValueChange(event.target.value, event);
}
else{
onValueChange(event.target.value);
}
};
return <TextField
className={props.class ? props.class : ""}
onChange={handleChange}
errorMessage={props.error ? props.error : ""}
label={props.label}
placeholder={props.placeholder ? props.placeholder : ""}
name={props.name ? props.name : ""}
value={props.value == undefined ? "" : props.value }
disabled={props.disabled == undefined ? false : props.disabled}
required={props.required == undefined ? false : props.required}
multiline={props.multiline == undefined ? false : props.multiline}
rows={props.rows == undefined ? 0 : props.rows}
autoAdjustHeight={props.autoAdjustHeight == undefined ? false : props.autoAdjustHeight}
underlined={props.underlined == undefined ? false : props.underlined}
type={props.type == undefined ? "text" : props.type}
{...otherProps}
/>;
};
TextFieldInput.propTypes = {
props: PropTypes.shape({
class: PropTypes.string,
error: PropTypes.string,
label: PropTypes.string.isRequired,
required: PropTypes.bool,
name: PropTypes.string,
value: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number
]),
disabled: PropTypes.bool,
placeholder: PropTypes.string,
multiline: PropTypes.bool,
rows: PropTypes.number,
autoAdjustHeight: PropTypes.bool,
underlined: PropTypes.bool,
returnEvent: PropTypes.bool,
type: PropTypes.string
}),
otherProps: PropTypes.object,
onValueChange: PropTypes.func.isRequired
};
export default TextFieldInput;
据我所知,Office UI结构没有附件组件,我将感谢任何帮助!
1条答案
按热度按时间guicsvcw1#
您可以使用spfx-controls-react提供的FilePicker组件,它将提供一个类似于SharePoint online的用户界面,并允许您从多个位置选择文件。
除此之外,你也可以使用input type=“file”,然后自定义你想要的方式。你可以参考以下链接:https://tympanus.net/codrops/2015/09/15/styling-customizing-file-inputs-smart-way/