<template>
<div id="xxxFullScreen">
<el-row :gutter="20">
<el-col :span="2">
<div class="grid-content bg-purple">
<p></p>
</div>
</el-col>
<el-col :span="19">
<div class="grid-content bg-purple">
<el-container>
<el-header style="background: darkgrey;">
<H1 style="margin-left: 380px">欢迎来到腾讯会议</H1>
</el-header>
<el-container>
<el-aside width="200px">
<el-button type="danger" style=" margin-top: 30px;margin-bottom: 20px;">退出会议</el-button>
<el-table :data="tableData" style="width: 100%">
<el-table-column prop="username" label="学生姓名" width="180"></el-table-column>
</el-table>
</el-aside>
<el-container>
<h1>会议名称 : {{comment1.meetingName}}</h1>
<el-main>
<el-table :data="comment1" height="400" border style="width: 100%">
<el-table-column prop="name" label="姓名" width="180"></el-table-column>
<el-table-column prop="comment" label="内容" width="180"></el-table-column>
</el-table>
<el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="textarea"></el-input>
<el-button type="primary" @click="sendComment">发送</el-button>
</el-main>
</el-container>
</el-container>
</el-container>
</div>
</el-col>
<el-col :span="1">
<div class="grid-content bg-purple">
<p></p>
</div>
</el-col>
</el-row>
</div>
</template>
<script>
export default {
data() {
return {
tableData: [],
textarea: "",
// comment: [],
comment1: []
};
},
methods: {
sendComment: function() {
this.axios({
method: "POST",
url: "http://localhost:8081/meeting/comment", // 成功
data: JSON.stringify({
comment: this.textarea
}),
withCredentials: true,
headers: {
"Content-Type": "application/json"
}
}).then(response => {
this.comment1 = response.data;
this.textarea = "";
});
},
shUsername: function() {
this.axios({
method: "POST",
url: "http://localhost:8081/meing/data",//之前写成http://127.0.0.1:8081/meing/data 不成功
data: JSON.stringify({
comment: this.textarea
}),
withCredentials: true,
headers: {
"Content-Type": "application/json"
}
}).then(response => {
console.log("hahha");
this.tableData = response.data;
console.log(response.data);
});
}
},
created() {
this.shUsername();
}
};
</script>
坑就在于这两个url 使用 localhost 和 127.0.0.1 要一致
时间有限 简要记录一下