首頁  >  文章  >  web前端  >  透過在vue專案中使用ueditor(詳細教學)

透過在vue專案中使用ueditor(詳細教學)

亚连
亚连原創
2018-06-01 14:43:153303瀏覽

下面我就為大家分享一篇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: {
  &#39;UE&#39;: &#39;UE&#39;,
 },

4.index.html中新增

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

#5.editor元件


#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(&#39;UE&#39;);// eslint-disable-line
export default {
 name: &#39;editorView&#39;,
 data: () => (
  {
   editor: null,
  }
 ),
 methods: {
  geteditor() {
   console.log(this.editor.getContent());
  },
 },
 mounted() {
  this.editor = UE.getEditor(&#39;editor&#39;);
 },
 destroyed() {
  this.editor.destroy();
 },
};
</script>
<style>
</style>

上面是我整理給大家的,希望今後會對大家有幫助。

相關文章:

vue實作樹狀選單效果

############VUE重點問題總結####### ########p5.js入門教學之鍵盤互動############################

以上是透過在vue專案中使用ueditor(詳細教學)的詳細內容。更多資訊請關注PHP中文網其他相關文章!

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