最简单粗暴新增公告功能
首先确定添加的页面为index.html
关键代码
<!-- 公告--> <el-table :data="tableData" style="width: 100%" > <el-table-column :sort-method="tableSortBy('prop_ShowCon')" sortable label="公告"> <template slot-scope="scope"> <atx-edit-inline :readonly="!user.admin" :value="scope.row.prop_ShowCon" @change="updateShow(scope.row.udid, $event)"> </atx-edit-inline> </template> </el-table-column> </el-table>
Script代码:
updateShow(udid, text) { // admin required $.ajax({ url: "/api/v1/devices/" + udid + "/properties", method: "put", contentType: "application/json", data: JSON.stringify({ "ShowCon": text, }) }).fail(ret => { if (ret.status == 400) { this.$message.error(ret.responseJSON.description) } else { this.$message.error(ret.responseText) } }) },
此方法是用表格显示数据,当然可以换成其他组件;
在要添加的位置先增加html代码,把script放到相应位置即可