欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue中使用Tinymce的示例代碼

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

1、安裝tinymce編輯器

npm i tinymce
npm i @tinymce/tinymce-vue

或:

yarn add tinymce
yarn add @tinymce/tinymce-vue

2、配置中文語言包

地址:中文語言包

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

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: {
        //編號(hào)
        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;
}
/*在頁(yè)面正常使用時(shí)不用加這個(gè)樣式,在彈窗使用時(shí),要加這個(gè)樣式,因?yàn)槭褂脧棿?,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)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 深入Vue-Router路由嵌套理解

    深入Vue-Router路由嵌套理解

    這篇文章主要介紹了深入Vue-Router路由嵌套理解,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-08-08
  • Vue程序調(diào)試和排錯(cuò)技巧分享

    Vue程序調(diào)試和排錯(cuò)技巧分享

    因?yàn)槌绦虻恼{(diào)試非常重要,程序猿可以利用好的調(diào)試方法去查找定位自己的問題所在之處,從而,達(dá)到糾正自己程序錯(cuò)誤的地方,健壯自己的程序,讓問題變得越來越少,程序變得越來越健康,所以本文給大家介紹了Vue程序調(diào)試和排錯(cuò)技巧,需要的朋友可以參考下
    2024-12-12
  • axios全局請(qǐng)求參數(shù)設(shè)置,請(qǐng)求及返回?cái)r截器的方法

    axios全局請(qǐng)求參數(shù)設(shè)置,請(qǐng)求及返回?cái)r截器的方法

    下面小編就為大家分享一篇axios全局請(qǐng)求參數(shù)設(shè)置,請(qǐng)求及返回?cái)r截器的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-03-03
  • vue axios基于常見業(yè)務(wù)場(chǎng)景的二次封裝的實(shí)現(xiàn)

    vue axios基于常見業(yè)務(wù)場(chǎng)景的二次封裝的實(shí)現(xiàn)

    這篇文章主要介紹了vue axios基于常見業(yè)務(wù)場(chǎng)景的二次封裝的實(shí)現(xiàn),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-09-09
  • vue 實(shí)現(xiàn)網(wǎng)頁(yè)截圖功能詳解

    vue 實(shí)現(xiàn)網(wǎng)頁(yè)截圖功能詳解

    這篇文章主要介紹了通過vue實(shí)現(xiàn)網(wǎng)頁(yè)截圖的功能,有興趣的童鞋可以了解一下
    2021-11-11
  • vuex中this.$store.commit和this.$store.dispatch的基本用法實(shí)例

    vuex中this.$store.commit和this.$store.dispatch的基本用法實(shí)例

    在vue的項(xiàng)目里常常會(huì)遇到父子組件間需要進(jìn)行數(shù)據(jù)傳遞的情況,下面這篇文章主要給大家介紹了關(guān)于vuex中this.$store.commit和this.$store.dispatch的基本用法的相關(guān)資料,需要的朋友可以參考下
    2023-01-01
  • Vue.js構(gòu)建你的第一個(gè)包并在NPM上發(fā)布的方法步驟

    Vue.js構(gòu)建你的第一個(gè)包并在NPM上發(fā)布的方法步驟

    這篇文章主要介紹了Vue.js構(gòu)建你的第一個(gè)包并在NPM上發(fā)布的方法步驟,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2019-05-05
  • 手寫Vue源碼之?dāng)?shù)據(jù)劫持示例詳解

    手寫Vue源碼之?dāng)?shù)據(jù)劫持示例詳解

    這篇文章主要給大家介紹了手寫Vue源碼之?dāng)?shù)據(jù)劫持的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-01-01
  • 一文帶你簡(jiǎn)單理解Vue的data為何只能是函數(shù)

    一文帶你簡(jiǎn)單理解Vue的data為何只能是函數(shù)

    如果data是一個(gè)函數(shù)的話,這樣每復(fù)用一次組件,就會(huì)返回一份新的data,下面這篇文章主要給大家介紹了關(guān)于簡(jiǎn)單理解Vue的data為啥只能是函數(shù)的相關(guān)資料,需要的朋友可以參考下
    2022-10-10
  • vue獲取驗(yàn)證碼倒計(jì)時(shí)組件

    vue獲取驗(yàn)證碼倒計(jì)時(shí)組件

    這篇文章主要為大家詳細(xì)介紹了vue獲取驗(yàn)證碼倒計(jì)時(shí)組件,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-08-08

最新評(píng)論