首頁  >  文章  >  web前端  >  vue專案中如何使用ueditor

vue專案中如何使用ueditor

php中世界最好的语言
php中世界最好的语言原創
2018-03-27 14:55:223069瀏覽

這次帶給大家vue專案中如何使用ueditor,vue專案中使用ueditor的注意事項有哪些,以下就是實戰案例,一起來看一下。

以vue-cli產生的專案為例

#1.static資料夾下先放入ueditor檔案

2.index.html新增下列程式碼

<script type="text/javascript" charset="utf-8" src="static/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="static/ueditor/ueditor.all.min.js"></script>

3.webpack.base.conf.js新增如下在配置

externals: {
  'UE': 'UE',
 },

4.index.html中新增

<script type="text/javascript">
 window.UEDITOR_HOME_URL = "/static/ueditor/";//配置路径设定为UEditor所放的位置
</script>

5.editor元件

<template>
 <p>
  <mt-button @click="geteditor()" type="danger">获取</mt-button>
  <script id="editor" type="text/plain" style="width:1024px;height:500px;"></script>
 </p>
</template>
<script>
const UE = require('UE');// eslint-disable-line
export default {
 name: 'editorView',
 data: () => (
  {
   editor: null,
  }
 ),
 methods: {
  geteditor() {
   console.log(this.editor.getContent());
  },
 },
 mounted() {
  this.editor = UE.getEditor('editor');
 },
 destroyed() {
  this.editor.destroy();
 },
};
</script>
<style>
</style>

相信看了本文案例你已經掌握了方法,更多精彩請關注php中文網其它相關文章!

推薦閱讀:

Canvas如何做出3D動態的Chart圖表

WebGL怎麼操作json與echarts圖表

以上是vue專案中如何使用ueditor的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn