import * as React from 'react'; import styles from './ReactNew.module.scss'; import { IReactNewProps } from './IReactNewProps'; import { escape } from '@microsoft/sp-lodash-subset'; import pnp, { sp, Web } from 'sp-pnp-js'; export default class ReactNew extends React.Component { constructor(props) { super(props); this.state = { checkboxs: { checkbox1: false, checkbox2: false, checkbox3: false, checkbox4: false, } } this.handle = this.handle.bind(this); this._addListItem = this._addListItem.bind(this); } public render(): React.ReactElement { return (
Welcome to SharePoint!

Customize SharePoint experiences using Web Parts.

{escape(this.props.description)}

Learn more123
checkbox1
checkbox2
checkbox3
checkbox4
); } componentDidMount() { } private handle(event) { let value = event.target.value; let { checkboxs } = this.state; checkboxs[value] = event.target.checked; this.setState({ checkboxs }); } private _addListItem() { let { checkboxs } = this.state; let cks = []; for (let key in checkboxs) { if (checkboxs[key]) { cks.push(key.toString()) } } let web = new Web(this.props.context.pageContext.web.absoluteUrl); web.lists.getByTitle("test").items.add({ Title: "Title", cks: { results: cks } }).then(response=>console.log(response)); } }