模板里面
<el-dialog :visible.sync="dialogVisible" width="30%" title="消息详情">
<el-input
type="textarea"
:value="message"
class="dialog-style"
readonly
rows="10"
></el-input>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">取 消</el-button>
</span>
</el-dialog>
methods里面 message是传过来没格式化的数据
informationHandler(message) {
//string转换成JSON对象
function strToObj(json) {
return eval("(" + json + ")");
}
this.dialogVisible = true;
let mesObj = strToObj(message);
//JSON对象转换成JSON字符串
this.message = JSON.stringify(mesObj, null, 4);
}
json格式数据展示在页面上
于 2022-03-01 13:29:20 首次发布