1.0.51 • Published 11 months ago

vue2-quill2-editor v1.0.51

Weekly downloads
-
License
ISC
Repository
-
Last release
11 months ago

How to use

<template>
  <div class="demo">
    <vue2-quill2-editor
      ref="vue2Quill2Editor"
      :upload-function="uploadFunction"
    >
    </vue2-quill2-editor>
    <CmsJournal></CmsJournal>
  </div>
</template>

<script>
import axios from 'axios'
import Vue from 'vue'
import Editor from 'vue2-quill2-editor/dist/index'
Vue.use(Editor)

export default {
  components: {Editor},
  data () {
    return {}
  },
  methods: {
    uploadFunction (range, fileList) {
      const headers = {
        'eptoken': '7856456e-7b5d-4f3a-be37-a98d0ba51d8d',
        'Content-Type': 'application/json'
      }

      let file = fileList[0]
      const fileName = file.name.toString()

      // 使用FormData构建请求
      const formData = new FormData()
      formData.append('file', file) // 添加文件
      formData.append('fileName', fileName)
      formData.append('linkId', '999')        //  示例字段
      formData.append('linkType', 'journal') //  示例字段
      formData.append('inText', 1)           // 示例字段

      axios.post('http://localhost:8090/file/upload', formData, {headers}).then(json => {
        const Delta = this.$refs.vue2Quill2Editor.quill.constructor.import('delta'); // 使用构造函数访问

        // 下面三行必填
        const cursorPosition = this.$refs.vue2Quill2Editor.quill.getSelection().index
        this.$refs.vue2Quill2Editor.quill.updateContents(new Delta().retain(cursorPosition).insert({image: json.data.data}))
        this.$refs.vue2Quill2Editor.quill.setSelection(cursorPosition + 1, 0)
      })
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1, h2 {
  font-weight: normal;
}

ul {
  list-style-type: none;
  padding: 0;
}

li {
  display: inline-block;
  margin: 0 10px;
}

a {
  color: #42b983;
}
</style>
1.0.51

11 months ago

1.0.49

11 months ago

1.0.48

11 months ago

1.0.47

11 months ago

1.0.46

11 months ago

1.0.45

11 months ago

1.0.43

11 months ago

1.0.42

11 months ago

1.0.41

11 months ago

1.0.40

11 months ago

1.0.39

11 months ago

1.0.38

11 months ago

1.0.37

11 months ago

1.0.36

11 months ago

1.0.35

11 months ago

1.0.34

11 months ago

1.0.33

11 months ago

1.0.32

11 months ago

1.0.31

11 months ago

1.0.30

11 months ago

1.0.29

11 months ago

1.0.28

11 months ago

1.0.27

11 months ago

1.0.26

11 months ago

1.0.25

11 months ago

1.0.24

11 months ago

1.0.22

11 months ago

1.0.21

11 months ago

1.0.20

11 months ago

1.0.19

11 months ago

1.0.18

11 months ago

1.0.17

11 months ago

1.0.16

11 months ago

1.0.15

11 months ago

1.0.14

11 months ago

1.0.13

11 months ago

1.0.12

11 months ago

1.0.11

11 months ago

1.0.10

11 months ago

1.0.9

11 months ago

1.0.8

11 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago