2017-10-06 91 views
0

您好,我用我.vue文件CK編輯器現在我CKEDITOR在VUE JS

<script> 
$(document).ready(function() { 
    CKEDITOR.replace('content', { 
     extraPlugins: 'mathjax', 
     mathJaxLib: 'http://cdn.mathjax.org/mathjax/2.6-latest/MathJax.js? 
     config=TeX-AMS_HTML', 
     height: 320, 
    }); 
}); 

初始化我的CKEditor在我home.blade.php在文件上的準備...但是當我在頁面上要去的地方CKEditor的使用路由器

<router-link to="/question/create"> 
    <a class="btn btn-primary"> 
     <i class="fa fa-plus" aria-hidden="true"></i> 
     <span class="nav-label">New Question</span> 
    </a> 
</router-link> 

CKEditor的沒有被加載放置意味着文本區域不被替換

screen shot of editor not being replaced

但是當我手動重新加載頁面就被替換很好..

screen shot of editor being replaced after reloading the page

我試圖

import './../../txt/ckeditor.js 

在我的文件的頂部,但它給這個錯誤...

未捕獲的語法錯誤:意外的代幣< 個app.js:72554遺漏的類型錯誤:無法設置的不確定

財產「目錄」我想從編輯器的目錄之一...... 請幫助我,如果我這樣做是錯誤的方式...

我看,我已經把它安裝它鉤,但我不知道如何..

或在工作圍繞什麼,我能做的就是重新加載使用

this.$router.go(this.$router.currentRoute) 

的頁面,但我不能找出調用這個,如果我把它掛在掛鉤頁面k中EEPS重裝也試過

window.location.href 

但結果卻是相同的textarea的不被用ckditor

回答

0

代替我認爲使用$(document).ready(function()...是原因。嘗試使用Vue的mounted()方法。

<script> 
    mounted() { 
    CKEDITOR.replace('content', { 
     extraPlugins: 'mathjax', 
     mathJaxLib: 'http://cdn.mathjax.org/mathjax/2.6-latest/MathJax.js? 
     config=TeX-AMS_HTML', 
     height: 320, 
    }); 
} 
</script> 
+0

感謝它的工作..... @理查德Matsen – rajesh

+0

,但現在當我重新加載頁面textarea的不被更換.. @理查德Matsen – rajesh

+0

這聽起來像是你可能需要更新'()'代替(或者兩者兼而有之(在這種情況下,將內部代碼移動到方法並從兩個生命週期鉤子中調用方法)。需要一些測試,但應該直接嘗試排列並找到一個有效的排列。 –