700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > wangeditor设置字体_自定义颜色 字体 字号

wangeditor设置字体_自定义颜色 字体 字号

时间:2020-10-08 09:55:05

相关推荐

wangeditor设置字体_自定义颜色 字体 字号

可通过`editor.config.colors` `editor.config.familys` `editor.config.fontsizes` 三个配置项来配置编辑器的颜色(字体颜色、背景色),字体,字号。**该操作必须再`editor.create()`方法之前执行**

![](/-01-29_56ab6d05af824.png)

代码示例:

```html

请输入内容...

var editor = new wangEditor('div1');

// 颜色

editor.config.colors = {

'#880000': '暗红色',

'#800080': '紫色',

'#ff0000': '红色'

};

// 字体

editor.config.familys = [

'宋体', '黑体', '楷体', '微软雅黑',

'Arial', 'Verdana', 'Georgia'

];

// 字号

editor.config.fontsizes = {

// 格式:'value': 'title'

1: '10px',

2: '13px',

3: '16px',

4: '19px',

5: '22px',

6: '25px',

7: '28px'

};

editor.create();

```

注意:字号的配置中,对象的`value`值必须是`1 2 3 4 5 6 7`这几个数字(全部或者选择其中几个),`title`可以自己修改。如:

```

// 字号

editor.config.fontsizes = {

// 格式:'value': 'title'

2: '小',

3: '中',

5: '大',

7: '特大'

};

```

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。