vue读取远程文件代码并使用codemirror预览

vue yekong 533℃
    <el-dialog title="代码详情" :visible.sync="showCodeDialog">
      <codemirror v-model="code" :options="options"></codemirror>
    </el-dialog>
import axios from "axios";
import {codemirror} from 'vue-codemirror'
// 核心样式
import {baseURL} from '@/config'
import 'codemirror/lib/codemirror.css'
// 引入主题后还需要在 options 中指定主题才会生效
import 'codemirror/theme/rubyblue.css'
import 'codemirror/mode/python/python.js'
getcode(e) {
      var that = this;
      axios({
        method: 'get',
        url: e,
        responseType: 'blob'
      })
        .then(function (response) {
          console.log(response.data)
          let blob = response.data
          let reader = new FileReader()
          reader.readAsBinaryString(blob)
          reader.onload = (e) => {
            console.log(e.target.result)
            that.code = e.target.result;
            that.showCodeDialog = true
          }
        });
    },
喜欢 (1)