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

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

![](https://box.kancloud.cn/2016-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: '特大'

};

```

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值