如何调试 Pebble.js 中的对象?
How can I debug Objects in Pebble.js?
我正在通过 ajax
获取
ajax(
{
url: ...,
type: 'json'
},
function(data) {
// Success!
console.log(data);
},
function(error) {
// Failure!
}
)
我得到
[HANDY] pebble-app.js:?: [object Object]
如果我知道要查找哪些属性,我可以通过 data.key
访问它们。但是如果对象具有未知属性或者我只是需要深度调试呢?
使用JSON.stringify so you can see the values of your object as a JSON string in the app log:
console.log(JSON.stringify(data));
很多 Pebble.js examples 使用它来调试。
我正在通过 ajax
获取ajax(
{
url: ...,
type: 'json'
},
function(data) {
// Success!
console.log(data);
},
function(error) {
// Failure!
}
)
我得到
[HANDY] pebble-app.js:?: [object Object]
如果我知道要查找哪些属性,我可以通过 data.key
访问它们。但是如果对象具有未知属性或者我只是需要深度调试呢?
使用JSON.stringify so you can see the values of your object as a JSON string in the app log:
console.log(JSON.stringify(data));
很多 Pebble.js examples 使用它来调试。