00.ionic4:11.緯度経度から歩いた距離を表示
差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン前のリビジョン次のリビジョン | 前のリビジョン | ||
00.ionic4:11.緯度経度から歩いた距離を表示 [2019/09/03] – [setInterval] adash333 | 00.ionic4:11.緯度経度から歩いた距離を表示 [2019/09/12] (現在) – [いまどきのJavaScript記法] adash333 | ||
---|---|---|---|
行 33: | 行 33: | ||
- | ==== setInterval ==== | + | ===== setInterval |
行 59: | 行 59: | ||
} | } | ||
| | ||
- | distance(lat1, | + | |
- | + | | |
- | + | | |
- | + | | |
- | } | + | |
+ | return 6371 * Math.acos(Math.cos(lat1) * Math.cos(lat2) * Math.cos(lng2 - lng1) + Math.sin(lat1) * Math.sin(lat2)); | ||
+ | } | ||
+ | |||
//途中 | //途中 | ||
行 102: | 行 105: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | ===== Vue.jsとsetInterval ===== | ||
+ | これからはじめるVue.js実践入門p37によると、setIntervalメソッドの配下では、thisは、Vueインスタンスではなく、グローバルオブジェクト(window)に変化してしまうため、あらかじめthatなどで固定しておく必要があるとのことです。 | ||
+ | |||
+ | < | ||
+ | export default { | ||
+ | name: ' | ||
+ | data: { | ||
+ | // 現在日時 | ||
+ | current: new Date() | ||
+ | }, | ||
+ | // 起動時にタイマーを設定 | ||
+ | created: function() { | ||
+ | let that = this; | ||
+ | // 1000ミリ秒スパンでcurrentプロパティを更新 | ||
+ | this.timer = setInterval(function() { | ||
+ | that.current = new Date(); | ||
+ | }, 1000); | ||
+ | }, | ||
+ | // 終了時にタイマーを破棄 | ||
+ | beforeDestroy: | ||
+ | clearInterval(this.timer); | ||
+ | }, | ||
+ | methods: { | ||
+ | | ||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | </ | ||
+ | |||
+ | これからはじめるVue.js実践入門p37 | ||
+ | |||
+ | < | ||
+ | <iframe style=" | ||
+ | </ | ||
+ | |||
+ | ===== Javascriptのthisについて ===== | ||
+ | |||
+ | https:// | ||
+ | thisって何?使い方を覚えて、JavaScriptをもっと楽しく使おう! | ||
+ | マサト | ||
+ | 2019/5/11 | ||
+ | |||
+ | https:// | ||
+ | @tsukishimaao | ||
+ | 2014年02月01日に更新 | ||
+ | windowオブジェクト | ||
+ | |||
+ | (引用ここから) | ||
+ | windowオブジェクトとはJavaScriptにあらかじめ用意されてるオブジェクトで、JavaScriptを何も書いてない状態でもwindowオブジェクトは利用する事が出来る。 | ||
+ | JavaScriptであらかじめ用意されている関数やオブジェクトは、みなwindowオブジェクトのプロパティです。HTMLデータを取得、操作する為の | ||
+ | window.document、URLなどの情報が格納されているwindow.locationなども、すべてwindowオブジェクトのプロパティです。 | ||
+ | (引用ここまで) | ||
+ | |||
+ | https:// | ||
+ | @takeharu | ||
+ | 2015年12月07日に更新 | ||
+ | JavaScriptの「this」は「4種類」?? | ||
+ | |||
+ | https:// | ||
+ | How to access the correct `this` inside a callback? | ||
+ | |||
+ | https:// | ||
+ | how to use setInterval in vue component | ||
+ | |||
+ | " | ||
+ | |||
+ | Using object methods as callbacks/ | ||
+ | what this refers to depends on how the function is called, not how it is defined. | ||
+ | そのため、解決策としては、 | ||
+ | -'' | ||
+ | -'' | ||
+ | -アロー関数を用いる | ||
+ | の3つがあるそうです。'' | ||
+ | |||
+ | |||
+ | https:// | ||
+ | Reactive Time with Vue.js | ||
+ | Mar 29, 2017 | ||
+ | Written by Jonnie Hallman | ||
+ | @destroytoday | ||
+ | |||
+ | ===== いまどきのJavaScript記法 ===== | ||
+ | |||
+ | https:// | ||
+ | @shibukawa | ||
+ | 2019年05月04日に更新 | ||
+ | イマドキのJavaScriptの書き方2018 | ||
+ | |||
+ | ===== Vue.jsでlocalStorage ===== | ||
+ | |||
+ | |||
+ | https:// | ||
+ | クライアントサイドストレージ | ||
+ | 最終更新日: | ||
+ | |||
+ | https:// | ||
+ | @ma7ma7pipipi | ||
+ | 2019年01月14日に投稿 | ||
+ | vue.js で json localstorage を使う | ||
+ | |||
+ | https:// | ||
+ | 2019年6月10日 | ||
+ | Vue.jsでinstallを使用せずにlocalStorageを使用する方法 | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
00.ionic4/11.緯度経度から歩いた距離を表示.1567512477.txt.gz · 最終更新: 2019/09/03 by adash333