strokestyle和strokewidth属性不起作用

时间:2013-08-30 10:30:30

标签: javascript jquery html css fabricjs

我想提供strokeStyle和strokewidth属性。

我正在尝试http://fabricjs.com/fabric-intro-part-2/#text的示例,但我无法看到对我的屏幕有什么影响?

小提琴:: http://jsfiddle.net/gvn3X/1/

var textWithStroke = new fabric.Text("Text with a stroke", {
  strokeStyle: '#ff1318',
  strokeWidth: 1
});
var loremIpsumDolor = new fabric.Text("Lorem ipsum dolor", {
  fontFamily: 'Impact',
  strokeStyle: '#c3bfbf',
  strokeWidth: 3
});

1 个答案:

答案 0 :(得分:2)

我认为该文档中存在错误,或者可能是语法已更改, 试试这个代码,我测试了它..它的工作原理..

var canvas = window._canvas = new fabric.Canvas('c');
  var text = new fabric.Text('Sample', {
 left: 100,
top: 100,
fill: 'navy',

 stroke: '#c3bfbf',
  strokeWidth: 3
 });
 var textWithStroke = new fabric.Text("Text with a stroke", {
 fontFamily: 'Impact',
  stroke: '#333',
   strokeWidth: 3,
   });
  canvas.add(text);
 canvas.add(textWithStroke);