Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 如何从sharepoint online SPFx Web部件使用azure认知搜索_Reactjs_Typescript_Sharepoint_Spfx_Azure Search .net Sdk - Fatal编程技术网

Reactjs 如何从sharepoint online SPFx Web部件使用azure认知搜索

Reactjs 如何从sharepoint online SPFx Web部件使用azure认知搜索,reactjs,typescript,sharepoint,spfx,azure-search-.net-sdk,Reactjs,Typescript,Sharepoint,Spfx,Azure Search .net Sdk,我最近与SPFx联系不多,所以我想我需要学习一点,:) 我想在这里使用这个NPM包: 进入基本的新SPFx web部件: 代码如下所示: export default class Azurecognitivesearchwebpart extends React.Component<IAzurecognitivesearchwebpartProps, {}> { public render(): React.ReactElement<IAzurecognitivesea

我最近与SPFx联系不多,所以我想我需要学习一点,:)

我想在这里使用这个NPM包:

进入基本的新SPFx web部件:

代码如下所示:

export default class Azurecognitivesearchwebpart extends React.Component<IAzurecognitivesearchwebpartProps, {}> {

  public render(): React.ReactElement<IAzurecognitivesearchwebpartProps> {    
  //var AzureSearch = require('azure-search');
  var client = AzureSearch({
    url: "https://x.search.windows.net",
    key: "xx",
    version: "2016-09-01", // optional, can be used to enable preview apis
    headers: { // optional, for example to enable searchId in telemetry in logs
      "x-ms-azs-return-searchid": "true",
      "Access-Control-Expose-Headers": "x-ms-azs-searchid"        
    }
  });

  // search the index
  client.search('azureblob-index-aihw', {search: "scott", top: 10}, function(err, results, raw){
    // raw argument contains response body as described here:
    // https://msdn.microsoft.com/en-gb/library/azure/dn798927.aspx
  });


    return (
      <div className={ styles.azurecognitivesearchwebpart }>
        <div className={ styles.container }>
          <div className={ styles.row }>
            <div className={ styles.column }>
              <span className={ styles.title }>Welcome to SharePoint!</span>
              <p className={ styles.subTitle }>Customize SharePoint experiences using Web Parts.</p>
              <p className={ styles.description }>{escape(this.props.description)}</p>
              <a href="https://aka.ms/spfx" className={ styles.button }>
                <span className={ styles.label }>Learn more</span>
              </a>
            </div>
          </div>
        </div>
      </div>
    );
  }
}
我错过了什么

还有一些

sp-webpart-workbench-assembly_default.js:26411 [1585151245901][OtherGlobalError.window.onerro] TypeError: Object(...) is not a function