質問編集履歴

1

質問の内容をapp.jpファイルのエラーメッセージに限定しました。

2019/09/03 07:53

投稿

menbou
menbou

スコア4

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,14 @@
1
+ ```ここに言語を入力
2
+
3
+ // This is a JavaScript file
4
+
5
+ //mobile backendのAPIキーを設定
6
+
7
+ var ncmb = new NCMB("478b876240b165602457fc1ba995fc7a6f10cfc798ab3c41c38fa1e196a58e77","b06fe6290232d5405fba3b5e25a42d330a3855e9ac85b0a77e9f7e2fb```
8
+
9
+ ```
10
+
1
- ### 前提・実現したいこと
11
+ ```### 前提・実現したいこと
2
12
 
3
13
 
4
14
 
@@ -10,7 +20,7 @@
10
20
 
11
21
  ソースコードの入力が終わりビルドの結果もOKでした。
12
22
 
13
- いざmonacaデバッガーに同期するとエラーメッセージが発生します。
23
+ いざmonacaデバッガーに同期(実装)するとエラーメッセージが発生します。
14
24
 
15
25
 
16
26
 
@@ -18,58 +28,164 @@
18
28
 
19
29
  ### 発生している問題・エラーメッセージ
20
30
 
21
- よくわかりませんのでApp Logに書かれているものを全て記述します。
22
31
 
23
- load:www/index.html (in cordova)
24
32
 
25
33
  Uncaught SyntaxError:Unexpected token<
26
34
 
27
35
  www/js/app.js/:1
28
36
 
29
- [Onsen UI]
37
+   
30
-
31
-    www/lib/onsenui/js/onsenui.min.js:2      
32
-
33
- Onsen UI is ready!
34
-
35
- www/index.html:17     
36
38
 
37
39
  ### 該当のソースコード
38
40
 
41
+ ```
42
+
43
+ コード// This is a JavaScript file
44
+
39
- [ www/js/app.js/:1]
45
+ //mobile backendのAPIキーを設定
46
+
47
+ var ncmb = new NCMB("478b876240b165602457fc1ba995fc7a6f10cfc798ab3c41c38fa1e196a58e77","b06fe6290232d5405fba3b5e25a42d330a3855e9ac85b0a77e9f7e2fb```
48
+
49
+ ```
40
50
 
41
51
 
42
52
 
43
- // This is a JavaScript file
53
+ function saveData(){
44
54
 
45
- //mobile backendのAPIキー
55
+ //クラス名して新規クラスを作成
46
56
 
47
- var ncmb = new NCMB("478b876240b165602457fc1ba995fc7a6f10cfc798ab3c41c38fa1e196a58e77","b06fe6290232d5405fba3b5e25a42d330a3855e9ac85b0a77e9f7e2fb
57
+ var Data = ncmb.DataStore("Data");
48
58
 
49
59
 
50
60
 
51
- [www/lib/onsenui/js/onsenui.min.js:2]
61
+ //Dataクラスのインスタンスを作成
52
62
 
53
- 全部のせきれないので初めの一部をのせます。
63
+ var data = new Data();
54
64
 
55
65
 
56
66
 
57
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.ons=e()}(this,function(){"use strict";function t(t){kt.set(t,!0)}function e(t){var e=wt.get(t,[])||[];wt.delete(t),e.forEach(function(t){return t()})}function n(n){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){};if(void 0===kt&&(kt=new WeakMap,wt=new WeakMap),function(t,e){wt.has(t)||wt.set(t,[]),wt.get(t).push(e)}(n,i),function(e){return e.childNodes.length>0&&t(e),kt.has(e)}(n))e(n);else{new MutationObserver(function(i){t(n),e(n)}).observe(n,{childList:!0,characterData:!0}),setImmediate(function(){t(n),e(n)})}}function i(t){t._destroy instanceof Function?t._destroy():t.remove()}function o(t,e){return e={exports:{}},t(e,e.exports),e.exports}function r(t){var e=gi.has(t),n=/^[a-z][.0-9_a-z]*-[\-.0-9_a-z]*$/.test(t);return!e&&n}function a(t){var e=t.isConnected;if(void 0!==e)return e;for(var n=t;n&&!(n.__CE_isImportDocument||n instanceof Document);)n=n.parentNode||(window.ShadowRoot&&n instanceof ShadowRoot?n.host:void 0);return!(!n||!(n.__CE_isImportDocument||n instanceof Document))}function s(t,e){for(var n=e;n&&n!==t&&!n.nextSibling;)n=n.parentNode;return n&&n!==t?n.nextSibling:null}function l(t,e){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Set,i=t;i;){if(i.nodeType===Node.ELEMENT_NODE){var o=i;e(o);var r=o.localName;if("link"===r&&"import"===o.getAttribute("rel")){var a=o.import;if(a instanceof Node&&!n.has(a)){n.add(a);for(var u=a.firstChild;u;u=u.nextSibling)l(u,e,n)}i=s(t,o);continue}if("template"===r){i=s(t,o);continue}var c=o.__CE_shadowRoot;if(c)for(var h=c.firstChild;h;h=h.nextSibling)l(h,e,n)}i=function(t,e){return e.firstChild?e.firstChild:s(t,e)}(t,i)}}function u(t,e,n){t[e]=n}var c={},h=function(){var t=window.getComputedStyle(document.documentElement,""),e=(Array.prototype.slice.call(t).join("").match(/-(moz|webkit|ms)-/)||""===t.OLink&&["","o"])[1];return function(t){return"-"+e+"-"+Q.hyphenate(t)}}(),d=function(t,e){return Object.keys(e).forEach(function(n){n in t.style?t.style[n]=e[n]:h(n)in t.style?t.style[h(n)]=e[n]:Q.warn("No such style property: "+n)}),t};d.clear=function(t){for(var e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"").split(/\s+/).reduce(function(t,e){return t.concat([Q.hyphenate(e),h(e)])},[]),n=[],i=t.style.length-1;i>=0;i--)!function(i){var o=t.style[i];(0===e.length||e.some(function(t){return 0===o.indexOf(t)}))&&n.push(o)}
67
+ //作成したインスタンスのaisatsuというフィールドに文字データを設定
58
68
 
59
- [www/index.html:17]
69
+ data.set("aisatsu", "hello, world!");
60
70
 
61
71
 
62
72
 
73
+ //設定したデータをmobile backendに保存
74
+
75
+ data.save()
76
+
77
+ .then(function(object) {
78
+
79
+ //成功する時の処理
80
+
81
+ $("#message").html("データ保存に成功!");
82
+
83
+ })
84
+
85
+ .catch(function(error) {
86
+
87
+ //エラーが発生する時の処理
88
+
89
+ $("#message").html("error:" + error.message);
90
+
91
+ });
92
+
93
+ }
94
+
95
+ //mobile backendへの会員登録を行うメソッド
96
+
97
+ function login (){
98
+
99
+ //テキストボックスからユーザー名とパスワードを取得
100
+
101
+ var userName = $("#user_name").val();
102
+
103
+ var password = $("#password").val();
104
+
105
+
106
+
107
+ //ユーザークラスのインスタンスを作成
108
+
109
+ var user = new ncmb.User();
110
+
111
+
112
+
113
+ //インスタンスにユーザー名とパスワードを設定
114
+
115
+ user.set("userName", userName)
116
+
117
+ .set("password", password);
118
+
119
+
120
+
121
+ //会員登録を行うsignUpByAccountメソッドを実行
122
+
123
+ user.signUpByAccount()
124
+
125
+ .then(function (object){
126
+
127
+ //成功する時の処理
128
+
129
+ ncmb.User.login(userName, password)
130
+
131
+ .then(function(data){
132
+
133
+ // ログイン後処理
134
+
135
+ getCurrentUser();
136
+
137
+ })
138
+
139
+ .catch(function(err){
140
+
141
+ // エラー処理
142
+
63
- console.log("Onsen UI is ready!");
143
+ console.log("error:" + error.message);
144
+
145
+ });
146
+
147
+ })
148
+
149
+ .catch(function (error){
150
+
151
+ //エラーが発生する時の処理
152
+
153
+ console.log("error:" + error.message);
154
+
155
+ });
156
+
157
+ }
158
+
159
+
160
+
161
+ //ログイン中のユーザー名を取得して画面に表示する
162
+
163
+ function getCurrentUser(){
164
+
165
+ //ログイン中の会員を取得
166
+
167
+ var user = ncmb.User.getCurrentUser();
168
+
169
+
170
+
171
+ //取得した会員のユーザー名を表示する
172
+
173
+ $("#current_user").text("ログイン中のユーザー名:" + user.get("userName"));
174
+
175
+ }
176
+
177
+
64
178
 
65
179
  ### 試したこと
66
180
 
181
+ app.jpファイルの1行目のコードを確認しましたが、Unexpected token<
182
+
183
+ に該当する箇所が見当たりません。
184
+
67
- 何度も試
185
+ どこがおかいのでしょうか?
68
186
 
69
187
 
70
188
 
71
189
  ### 補足情報(FW/ツールのバージョンなど)
72
190
 
73
-
74
-
75
- ここにより詳細な情報記載してください。
191
+ mobile backendのサンプルアプリ使用しています