我必须从 indexedDB 返回查询结果,但结果仅在onsuccess事件处理程序中可用。
1 function listPeople(){
...
4 var open = indexedDB.open("AccordionDatabase",1),
5 res;
6
7 open.onsuccess = function(){
8 var db = open.result;
9 var transaction = db.transaction("PeopleStore", "readwrite");
10 var store = transaction.objectStore("PeopleStore");
11 var request = store.getAll();
12 request.onsuccess = function(event){
13 res = event.target.result;
14 console.log(res);
15 };
16
17 // Close the db when the transaction is done
18 transaction.oncomplete = function() {
19 db.close();
20 };
21
22 };
23 return res; …Run Code Online (Sandbox Code Playgroud) 我正在使用 Fabric JS 实现画布,并发现了一个有趣的问题。
从图中可以看出,左边的文字字体模糊,右边的文字字体清晰。也就是说,文本在某些地方变得模糊,而在其他地方变得清晰。
var radius = 50;
var circle2 = new fabric.Circle({
radius: Math.sqrt(3) * radius / 2,
fill: '#FFF',
opacity: 0.5
});
var text2 = new fabric.IText('Anant Jadhav ANANT dfds sdss sd...', {
fontSize: 10,
textAlign: "center",
left: Math.sqrt(3) * radius / 2,
top: Math.sqrt(3) * radius / 2,
originX: "center",
originY: "center",
lineHeight: 12,
fontFamily: 'SanFrancisco',
fontWeight: 'bold',
fill: '#FFF',
opacity: 0.5
});
var element1 = new fabric.Group([myPoly, formatted], {
left: 4 * radius, …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用d3.js绘制折线图.
function lineChart(){
...
}
function update(){
...
var lineChart = lineChart()
.x(d3.scale.linear().domain([2011, 2014]))
.y(d3.scale.linear().domain([0, 1000000]));
...
}
Run Code Online (Sandbox Code Playgroud)
但控制台说Uncaught TypeError: lineChart is not a function.
如何解决这个问题?
javascript ×3
canvas ×1
closures ×1
d3.js ×1
fabricjs ×1
html ×1
html5-canvas ×1
indexeddb ×1
jquery ×1