locaforage getItem() 未执行
locaforage getItem() is not executing
$localForage.getItem('brandChainNames', function(err, data) {
// The same code, but using ES6 Promises.
console.log('_storedValue: '+ data);
});
到目前为止还没有密钥(在工具->存储透视中验证)。但是该控制台输出不打印任何内容(在 Firefox 中)。有人可以告诉我可能是什么问题。它前后的控制台输出,打印正常。
编辑:
修改代码如下:
var hallabolo = $localForage.getItem('brandChainNames', function(err, data) {
// The same code, but using ES6 Promises.
console.log('_storedValue: '+ data);
});
angular.toJson(hallabolo) 打印 {}
试过:
1.JSON.stringify(hallabolo)=='{}'
//returns假
2.Object.keys(hallabolo).length
// returns 1
3. jQuery.isEmptyObject(hallabolo)
// returns 假
4. angular.isObject(hallabolo)
// returns 真
更不用说 type of 'undefined'
,null 等不起作用,因为 hallabolo 是一个对象
$localForage.getItem('brandChainNames', function(err, data) {
// The same code, but using ES6 Promises.
console.log('_storedValue: '+ data);
});
不工作但以下工作:
$localForage.getItem('brandChainNames').then(function(data) {
// The same code, but using ES6 Promises.
console.log('_storedValue: '+ data);// data is printed as undefined, as expected
});
任何人,为什么?
$localForage.getItem('brandChainNames', function(err, data) {
// The same code, but using ES6 Promises.
console.log('_storedValue: '+ data);
});
到目前为止还没有密钥(在工具->存储透视中验证)。但是该控制台输出不打印任何内容(在 Firefox 中)。有人可以告诉我可能是什么问题。它前后的控制台输出,打印正常。
编辑: 修改代码如下:
var hallabolo = $localForage.getItem('brandChainNames', function(err, data) {
// The same code, but using ES6 Promises.
console.log('_storedValue: '+ data);
});
angular.toJson(hallabolo) 打印 {}
试过:
1.JSON.stringify(hallabolo)=='{}'
//returns假
2.Object.keys(hallabolo).length
// returns 1
3. jQuery.isEmptyObject(hallabolo)
// returns 假
4. angular.isObject(hallabolo)
// returns 真
更不用说 type of 'undefined'
,null 等不起作用,因为 hallabolo 是一个对象
$localForage.getItem('brandChainNames', function(err, data) {
// The same code, but using ES6 Promises.
console.log('_storedValue: '+ data);
});
不工作但以下工作:
$localForage.getItem('brandChainNames').then(function(data) {
// The same code, but using ES6 Promises.
console.log('_storedValue: '+ data);// data is printed as undefined, as expected
});
任何人,为什么?