简体   繁体   English

Pebble JavaScript

[英]Pebble JavaScript

i am currently writing a watch app for my pebble time steel and are struggling as i try to introduce time synchronization. 我目前正在为我的卵石计时表编写一个手表应用程序,并且在尝试引入时间同步时正处于挣扎中。 basically my code so far has all my lessons imported in as variables and i have an if-else statement to decide what day it is. 到目前为止,基本上我的代码基本上将所有课程作为变量导入,并且我有一条if-else语句来决定今天是哪一天。

main.on('click', 'select', function(e) {
var d = new Date();
var n = d.getDay();
if (n == '1' ){
var h = d.getHours();
console.log(h);
var hm1 = 'm' + h;
console.log (hm1);
[hm1].show();
 }

This is only some of the code and i have had it work with just 'lesson1.show' before. 这只是其中的一些代码,我之前只使用过“ lesson1.show”来工作。 i know the console logs are not necessary but they are useful for trouble shooting (sometimes;D). 我知道控制台日志不是必需的,但对于解决问题很有用(有时; D)。

var m9 = new UI.Card();
m9.title('Lesson 1');
m9.subtitle('Maths');
m9.body('08:55 - 09:54');

This is how i have the days laid out, from my illeducated mind this seems it would work but it doesn't. 这是我安排的日子,从我受过高等教育的人看来,这似乎可行,但事实并非如此。 All i get is: 我所得到的是:

[PHONE] pebble-app.js:?: Timetable:343 21
[PHONE] pebble-app.js:?: Timetable:345 m21
[PHONE] pebble-app.js:?: Timetable:2221 JavaScript Error:
TypeError: [hm1].show is not a function
at null.<anonymous> (app.js:235:23)
at emitToHandlers (lib/emitter.js:121:17)
at Emitter.emit (lib/emitter.js:141:35)
at Window._emit (ui/window.js:274:12)
at Function.Window.emit (ui/window.js:286:17)
at Function.Window.emitClick (ui/window.js:301:17)
at Object.SimplyPebble.onPacket (ui/simply-pebble.js:1436:14)
at Array.SimplyPebble.onAppMessage (ui/simply-pebble.js:1480:18)
at Object.PebbleEventListener.dispatchEvent (webview_startup.js:143:50)

Any help is appreciated :D 任何帮助表示赞赏:D

如果有人在寻找类似问题,请使用eval语句,这有助于将变量合并为javascript函数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM