0

我正在为 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;

任何想法?

4

2 回答 2

1

像这样的东西:

import { GetCurrentCtx } from './filepath_for_this_function_export'
于 2017-02-21T10:30:50.887 回答
0

只是import文件/组件你在哪里method

于 2017-02-21T09:34:58.610 回答