如何从Reactjs调用其他库方法

时间:2017-02-21 07:56:28

标签: reactjs sharepoint-2013 sharepoint-jsom

我正在为SharePoint 2013页面构建Reactjs组件。在SharePoint JSOM中,我可以通过调用GetCurrentCtx()来获取当前上下文。我想在我的ReactJs组件中调用此方法,但我不知道该怎么做:

import React from 'react';

class TestComponent extends React.Component {

    constructor(props){
        super(props);
        this.state = {likesCount:0, listTitle:''};
        this.onLike = this.onLink.bind(this);
    }

    onLink(e){
        e.preventDefault();
        var ctx = GetCurrentCtx(); //<- this line doesn't work.
        this.setState({listTitle:ctx.ListTitle});
        return false;
    }

    render(){
        return (
            <div>
                <div>List Title: {this.state.listTitle}</div>
                <div><button onClick={this.onClick}>Get List Title</button></div>
            </div>
        );
    }
}
export default TestComponent;

有什么想法吗?

2 个答案:

答案 0 :(得分:0)

只需method个文件/组件,即'charset' => 'utf8', 'driver_options' => array( PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'' )

答案 1 :(得分:0)

类似的东西:

import { GetCurrentCtx } from './filepath_for_this_function_export'