开头一句mmp

tmd换位置了也没个提示!!!!

坑死爹了

<template>
<div>
<input type="text" v-model="text">
<button @click="sendMessage">发送消息</button>
<br>
<br>
<div>{{data}}</div>
</div>
</template>
<script>
import SockJS from 'sockjs-client'
import Stomp from 'webstomp-client'
export default {
name: 'ChatRoom',
data () {
return {
text: '',
data: '',
stompClient: null
}
},
mounted () {
if ('WebSocket' in window) {
this.initWebSocket()
} else {
alert('当前浏览器 Not support websocket')
}
},
methods: {
sendMessage () {
this.stompClient.send('/app/hello', JSON.stringify(this.text), {})
},
initWebSocket () {
this.connection()
},
connection () {
const socket = new SockJS(this.$baseUrl + '/chat')
this.stompClient = Stomp.over(socket)
this.stompClient.connect({}, (frame) => {
this.stompClient.subscribe('/topic/greetings', (greeting) => {
console.log(JSON.parse(greeting.body))
})
})
}
}
}
</script> <style scoped> </style>

重点是{}参数放最后面!!!!!

哎我擦

接口代码:

package org.just.computer.mathproject.Controller.WebSocket;

import org.just.computer.mathproject.Bean.Message;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Controller; import java.security.Principal; @Controller
public class GreetingController {
@MessageMapping("/hello")
@SendTo("/topic/greetings")
public Message greeting(String content, Principal pl) throws Exception{
Message message = new Message();
message.setContent(content);
message.setName(pl.getName());
return message;
}
}

Vue Stomp+SocketJS 数据报错[Object object]的更多相关文章

  1. Vue的报错:Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>'

    Vue的报错:Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>' ...

  2. Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object’#<Object>‘的解决方法

    发现问题 运行一下以前的一个Vue+webpack的 vue仿新闻网站  小项目,报错 由于自己vue学习不深入,老是这个报错,找了好久(确切的说是整整一下午^...^)才找到原因 -v- Uncau ...

  3. Vue 使用自定义组件时报错:Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>'

    自己试做了一下vue的插件 参考element-ui: 写了一个组件 import message from './packages/message/index.js'; const install ...

  4. vue运行报错error:Cannot assign to read only property 'exports' of object '#<Object>'

    用weex做项目的时候,npm start 之后一直报错error:Cannot assign to read only property 'exports' of object '#<Obje ...

  5. Vue不兼容IE8原因以及Object.defineProperty详解

    Vue不兼容IE8原因以及Object.defineProperty详解 原因概述: Vue.js使用了IE8不能模拟的ECMAScript5特性. Vue.js支持所有兼容ES5的浏览器. Vue将 ...

  6. 在Vue中使用i18n 国际化遇到 Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>'

    最近用Vue在搭建前端框架,在引用i18n时,运行的时候报错:Uncaught TypeError: Cannot assign to read only property 'exports' of ...

  7. oracle创建包后执行报错:object omgmig.test_package is invalid.

    今天学习了一下oracle的包的写法,然后碰到这么个问题.包声明和包主体都正确,但是就是执行报错:object omgmig.test_package is invalid. 这是会报错的sql,看起 ...

  8. 安装Django时报错'module' object has no attribute 'lru_cache'

    使用pip方法安装Django时报错'module' object has no attribute 'lru_cache' 解决办法如下 命令行输入命令sudo pip install Django ...

  9. python报错'str' object is not callable

    >>> x=1.235 >>> int(x) 1 >>> str="fsgavfdbafdbntsbgbt" >> ...

随机推荐

  1. 用BAPI_ACC_DOCUMENT_POST过账生成凭证

    根据前台需要输入参数,在bapi里面传值,不同业务所需参数不同. dome1: "bapi结构赋值     LOOP AT lt_item INTO lw_item.       wa_do ...

  2. 配置VS Code+React开发环境

    1.安装node+npm 2.安装VS Code 3.选择工作区文件夹——右键点击在终端中打开 4.按照Using React in Visual Studio Code的文档进行操作 npm ins ...

  3. linux内核 mtd分区

    首先 内核配置需要打开MTD选项 Memory Technology Devices (MTD) ---> 如果是NOR Flash,需要选择Common Flash Interface (CF ...

  4. 在ubuntu15.10上编译arm-linux环境使用的log4c步骤

    步骤: 1.下载log4c源码 2.解压源码包,我解压后的路径是:/home/cc/Downloads/log4c-1.2.4 3.执行以下shell脚本: #!/bin/sh mkdir /home ...

  5. openssl rsa加密,解密以及X509证书的使用

    Openssl的相关使用 生成证书 生成证书见:使用 openssl 生成证书 代码实现 Cert.h #ifndef _CERT_H #define _CERT_H ///header files ...

  6. 关于 from scipy.misc import imread, imresize, imsave 报错的问题

    使用 from scipy.misc import imread, imresize, imsave 时出现报错,查找后发现新版本的Scipy不再包含imread,imresize,imsave,需要 ...

  7. 阿里云ECS服务器,修改实例密码,查看CPU核数,内存,阿里云服务器关机了怎么办?

    新买的ECS服务器是没有密码的,需要重置密码(root,P@ssw0rd),并重启: 查看CPU核数和内存: 阿里云服务器关机了,不用怕,登录阿里云,可以启动和关闭

  8. C++ class 内的 [] 重载示例。

    #include <iostream> // overloading "operator [] " inside class ///////////////////// ...

  9. Shiro内置过滤器

    Shiro内置过滤器 DefaultFilter 枚举类定义了shiro所有的默认过滤器. package org.apache.shiro.web.filter.mgt; public enum D ...

  10. ubuntu 查看版本

    cat /etc/proc 可以查看是16.04还是18.04