2018-02-12 18:05:37 +08:00
|
|
|
<template>
|
2018-06-10 08:39:06 +08:00
|
|
|
<d2-container>
|
2018-06-10 16:36:09 +08:00
|
|
|
<d2-demo-page-header slot="header" title="导出文本"/>
|
2018-02-12 18:25:17 +08:00
|
|
|
<el-input
|
|
|
|
|
type="textarea"
|
2018-02-12 18:34:20 +08:00
|
|
|
:autosize="{minRows: 2, maxRows: 4}"
|
2018-02-12 22:00:29 +08:00
|
|
|
placeholder="请输入内容 然后点击保存按钮导出文本文档"
|
2018-02-12 18:25:17 +08:00
|
|
|
v-model="text">
|
|
|
|
|
</el-input>
|
2018-06-09 22:39:05 +08:00
|
|
|
<div class="d2-mt d2-mb">
|
2018-02-12 18:38:22 +08:00
|
|
|
<el-button type="primary" @click="exportTxt">
|
2018-06-10 09:21:26 +08:00
|
|
|
<d2-icon name="download"/>
|
2018-02-12 18:38:22 +08:00
|
|
|
保存为 txt
|
|
|
|
|
</el-button>
|
2018-02-12 18:25:17 +08:00
|
|
|
</div>
|
2018-06-10 09:14:10 +08:00
|
|
|
<d2-markdown url="/static/md/插件 - 导出.md"/>
|
2018-06-10 08:39:06 +08:00
|
|
|
</d2-container>
|
2018-02-12 18:05:37 +08:00
|
|
|
</template>
|
2018-02-12 18:25:17 +08:00
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
text: ''
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
exportTxt () {
|
2018-02-12 22:00:29 +08:00
|
|
|
// 校验是不是空
|
|
|
|
|
if (this.text === '') {
|
|
|
|
|
this.$message('虽然可以为空 但是出于体验不建议这样 还是写点东西吧')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
// 导出
|
2018-02-12 18:34:20 +08:00
|
|
|
this.$export.txt({
|
|
|
|
|
text: this.text,
|
|
|
|
|
title: '文本'
|
|
|
|
|
})
|
2018-02-12 18:37:02 +08:00
|
|
|
.then(() => {
|
|
|
|
|
this.$message('导出文本成功')
|
|
|
|
|
})
|
2018-02-12 18:25:17 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|