1.基本的な手順:
- 1.1インストール
npm install vue-quill-editor
- 1.2部分登録
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
import {
quillEditor } from 'vue-quill-editor'
export default {
components: {
quillEditor}
}
- 1.3使用
//content富文本内容 editorOption富文本配置
<quill-editor v-model="content" :options="editorOption"/>
new Vue({
data () {
return {
// 富文本配置
editorOption: {
}
}
}
})
2.リッチテキストの基本構成:
以下に示すように:
ランディングコードの構成:
var toolbarOptions = [
['bold', 'italic', 'underline', 'strike'], // toggled buttons
['blockquote', 'code-block'],
[{
'header': 1 }, {
'header': 2 }], // custom button values
[{
'list': 'ordered'}, {
'list': 'bullet' }],
[{
'script': 'sub'}, {
'script': 'super' }], // superscript/subscript
[{
'indent': '-1'}, {
'indent': '+1' }], // outdent/indent
[{
'direction': 'rtl' }], // text direction
[{
'size': ['small', false, 'large', 'huge'] }], // custom dropdown
[{
'header': [1, 2, 3, 4, 5, 6, false] }],
[{
'color': [] }, {
'background': [] }], // dropdown with defaults from theme
[{
'font': [] }],
[{
'align': [] }],
['clean'] // remove formatting button
];
var quill = new Quill('#editor', {
modules: {
toolbar: toolbarOptions
},
theme: 'snow'
});
3.対応するスタイル設定:
背景色-背景
太字-太字
色-色
フォント-フォント
インラインコード-コード
斜体-斜体
リンク-リンク
サイズ-サイズ
ストライクスルー-ストライクスーパー
スクリプト/添え字-スクリプト
アンダーライン-アンダーライン
引用-ブロック引用
タイトル-ヘッダー
インデント-インデント
リスト-リスト
テキストアラインメント-
テキストの方向を揃える-方向
コードブロック-コード-ブロック
式-式
画像-画像
ビデオ-ビデオ
クリアフォントスタイル-クリーン
応答スタイルを生成するオプションのモジュールの下のツールバーに必要なスタイルを記述します。
data(){
return {
Option:{
modules:{
toolbar:[
//标题 - header
[{
'header': 1 }, {
'header': 2 }],
//列表 - list
[{
'list': 'ordered'}, {
'list': 'bullet' }],
//上标/下标 - script
[{
'script': 'sub'}, {
'script': 'super' }],
//缩进 - indent
[{
'indent': '-1'}, {
'indent': '+1' }],
//文本方向 - direction
[{
'direction': 'rtl' }],
]
}
}
}
},
表示効果は次のとおりです。
自分のプロジェクトで使用されているプラグインをいくつか共有します。優れたプラグインがある場合は、コメントして一緒に調べてみましょう。