# 多行文本

# 创建

使用 new fabric.Textbox(string, object) 方法创建多行文本

当设置好元素宽度后,文本内容会根据单词换行。但是中文不换行,可以设置居中

# show code

const text = new fabric.Textbox('Please translate this sentence for me', {
  fill: '#f00',
  stroke: 'blue',
  strokeWidth: 2,
  width: 300,
})
1
2
3
4
5
6

# show code

const text = new fabric.Textbox('点击可编辑,但是不换行不换行不换行不换行', {
  fill: '#f00',
  stroke: 'blue',
  strokeWidth: 2,
  width: 300,
})
1
2
3
4
5
6

# show code

const text = new fabric.Textbox('我可以居中', {
  fill: '#f00',
  stroke: 'blue',
  strokeWidth: 2,
  textAlign: 'center',
  width: 300,
})
1
2
3
4
5
6
7
最后更新时间: 12/8/2023, 3:40:46 PM