鍍金池/ 問(wèn)答/HTML/ _aStomp2.default.client is not a functio

_aStomp2.default.client is not a function

import React from 'react';
import AStomp from '../../utils/aStomp'

class Basic extends React.Component {

    constructor() {
        super();
    }

    componentDidMount() {
        var aClient = null;
        aClient = AStomp.client('ws://10.0.5.232:61623');
        aClient.console('消息到來(lái)了')
    }

    render() {
        var divStyle = {

        }

        return (

            <div id style={divStyle} className='data-line'>
                <h1>indexStomp</h1>
                <h1>A</h1>
            </div>
        )
    }
}

export default Basic;
/*
 *  時(shí)間:2018年1月28日
 */

(function() {
    var Byte, Client, Frame, Stomp,
        __hasProp = {}.hasOwnProperty,
        __slice = [].slice;

    Byte = {
        LF: '\x0A',
        NULL: '\x00'
    };



    Client = (function() {
        var now;

        function Client(ws) {
            this.ws = ws;
            this.ws.binaryType = "arraybuffer";
            this.counter = 0;
            this.connected = false;
            this.heartbeat = {
                outgoing: 10000,
                incoming: 10000
            };
            this.maxWebSocketFrameSize = 16 * 1024;
            this.subscriptions = {};
            this.partialData = '';
        }

        Client.prototype.console = function(message) {
            console.log(message)
        };







        return Client;

    })();

    Stomp = {
        VERSIONS: {
            V1_0: '1.0',
            V1_1: '1.1',
            V1_2: '1.2',
            supportedVersions: function() {
                return '1.1,1.0';
            }
        },
        client: function(url, protocols) {
            var klass, ws;
            if (protocols == null) {
                protocols = ['v10.stomp', 'v11.stomp'];
            }
            klass = Stomp.WebSocketClass || WebSocket;
            ws = new klass(url, protocols);
            return new Client(ws);
        },
        over: function(ws) {
            return new Client(ws);
        },
        Frame: Frame
    };

    if (typeof exports !== "undefined" && exports !== null) {
        exports.Stomp = Stomp;
    }

    if (typeof window !== "undefined" && window !== null) {
        Stomp.setInterval = function(interval, f) {
            return window.setInterval(f, interval);
        };
        Stomp.clearInterval = function(id) {
            return window.clearInterval(id);
        };
        window.Stomp = Stomp;
    } else if (!exports) {
        self.Stomp = Stomp;
    }

}).call(this);

圖片描述

圖片描述

回答
編輯回答
墨小羽

剛試了下沒(méi)問(wèn)題,換成import {AStomp} from '../utils/Stomp'試試

2018年4月18日 13:01
編輯回答
擱淺

刷聲望刷聲望刷聲望,打擾了打擾了

2018年4月11日 08:26