最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue中使用Tinymce的示例代碼

 更新時間:2023年08月17日 09:00:34   作者:一個葉小小  
這篇文章主要介紹了vue中使用Tinymce的示例,本文通過示例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下

1、安裝tinymce編輯器

npm i tinymce
npm i @tinymce/tinymce-vue

或:

yarn add tinymce
yarn add @tinymce/tinymce-vue

2、配置中文語言包

地址:中文語言包

注:最好將語言包放在public/langs/或static/langs/目錄下,下面組件將會引用

3、封裝組件

在components 目錄下新建 tinymce.vue

<template>
    <div>
        <Editor :id="tinymceId" :init="init" :disabled="disabled" v-model="myValue"></Editor>
    </div>
</template>
<script>
//引入tinymce-vue
import Editor from '@tinymce/tinymce-vue'
//公共的圖片前綴
//import Global from "./Global";
export default {
    components: { Editor },
    props: {
        //編號
        id: {
            type: String
        },
        //內(nèi)容
        value: {
            type: String,
            default: ''
        },
        //是否禁用
        disabled: {
            type: Boolean,
            default: false
        },
        //插件
        plugins: {
            type: [String, Array],
            default: 'preview searchreplace autolink directionality visualblocks visualchars fullscreen image link media code codesample table charmap pagebreak nonbreaking anchor insertdatetime advlist lists wordcount help emoticons autosave autoresize formatpainter',
        },
        //工具欄
        toolbar: {
            type: [String, Array],
            default: 'code undo redo restoredraft | fullscreen | cut copy paste pastetext | forecolor backcolor bold italic underline strikethrough link anchor | alignleft aligncenter alignright alignjustify outdent indent | \
    styleselect formatselect fontselect fontsizeselect | bullist numlist | blockquote subscript superscript removeformat | \
    table image media charmap emoticons hr pagebreak insertdatetime print preview | bdmap indent2em lineheight formatpainter axupimgs',
        }
    },
    data() {
        let that = this;
        return {
            tinymceId: this.id || 'vue-tinymce' + Date.parse(new Date()),
            myValue: this.value,
            init: {
                //漢化,路徑是自定義的
                language_url: '/tinymce/langs/zh_CN.js',
                language: 'zh_CN',
                //皮膚
                skin: 'oxide',
                //插件
                plugins: this.plugins,
                //工具欄
                toolbar: this.toolbar,
                //高度
                height: 500,
                //圖片上傳
                images_upload_handler: function (blobInfo, success, failure) {
                    //文件上傳的formData傳遞
                    let formData = new FormData();
                    formData.append('file', blobInfo.blob(), blobInfo.filename());
                    //上傳的api,和后端配合,返回的是圖片的地址,然后加上公共的圖片前綴
                    that.$api.system.uploadImage(formData).then(res => {
                        var url = "tt"http://Global.baseUrlImg + res;
                        console.log(url)
                        success(url)
                    }).catch(res => {
                        failure('圖片上傳失敗')
                    });
                }
            }
        }
    },
    methods: {
    },
    watch: {
        //監(jiān)聽內(nèi)容變化
        value(newValue) {
            this.myValue = newValue
        },
        myValue(newValue) {
            this.$emit('input', newValue)
        }
    }
}
</script>
<style>
.tox-notifications-container {
    display: none;
}
/*在頁面正常使用時不用加這個樣式,在彈窗使用時,要加這個樣式,因為使用彈窗,z-index層數(shù)比較低,工具欄的一些工具不能使用,要將z-index層數(shù)提高。*/
.tox.tox-silver-sink.tox-tinymce-aux {
    z-index: 2100 !important;
}</style>

4、引用組件

新建test.vue

<template>
    <div>
        <TinymceEditor :value="content" @input="newContent"></TinymceEditor>
    </div>
</template>
<script>
import TinymceEditor from "./components/tinymce.vue"
export default {
    components: {
        TinymceEditor
    },
    data() {
        return {
            content: ""
        }
    },
    methods: {
        // 獲取富文本的內(nèi)容
        newContent(val) {
            this.content = val; // 直接更新 content 屬性
        }
    }
}
</script>

注:文件引入路徑是關(guān)鍵

到此這篇關(guān)于vue中使用Tinymce的文章就介紹到這了,更多相關(guān)vue使用Tinymce內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • layui實際項目使用過程中遇到的兼容性問題及解決

    layui實際項目使用過程中遇到的兼容性問題及解決

    這篇文章主要介紹了layui實際項目使用過程中遇到的兼容性問題及解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-04-04
  • Vue組件之間的通信你知道多少

    Vue組件之間的通信你知道多少

    這篇文章主要為大家詳細(xì)介紹了Vue組件之間的通信,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來幫助
    2022-02-02
  • Vue?Router組合布局用法詳解

    Vue?Router組合布局用法詳解

    今天我們用一種新的布局方式,使用路由視圖來實現(xiàn)布局樣式,本文將給大家介紹如何使用Vue?Router組合布局,文中有詳細(xì)的代碼示例供大家參考,感興趣的同學(xué)可以跟著小編一起學(xué)習(xí)
    2023-05-05
  • 使用webpack-obfuscator進行代碼混淆及報錯解決過程

    使用webpack-obfuscator進行代碼混淆及報錯解決過程

    隨著前端應(yīng)用的復(fù)雜度增加,保護客戶端的JavaScript代碼變得更為重要,webpack-obfuscator插件通過對代碼進行混淆,如變量重命名、字符串加密等,提高代碼的保密性,防止源碼被輕易查看或修改
    2024-10-10
  • 最新評論

    太康县| 璧山县| 桦甸市| 安多县| 张家界市| 治县。| 土默特左旗| 涞水县| 荣成市| 鄂托克前旗| 富民县| 房产| 铁力市| 凭祥市| 扶风县| 乌海市| 桂阳县| 林西县| 略阳县| 新丰县| 青神县| 延津县| 松桃| 青岛市| 陆川县| 绍兴市| 赫章县| 阿瓦提县| 安塞县| 腾冲县| 郸城县| 都江堰市| 乌拉特中旗| 普安县| 怀集县| 台安县| 金沙县| 长海县| 东乡族自治县| 渑池县| 镇沅|