Skip to content

Commit

Permalink
import Babel Polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasonnn committed May 31, 2017
1 parent 390e578 commit c678552
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 29 deletions.
31 changes: 2 additions & 29 deletions 31. Fetch-API/index.html
Expand Up @@ -3,6 +3,7 @@
<head>
<title>Fetch API Demo (Vue)</title>
<meta charset="utf-8">
<script src="lib/polyfill.min.js"></script>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="//cdn.polyfill.io/v2/polyfill.min.js?features=fetch"></script>
<link rel="stylesheet" href="css/style.css">
Expand Down Expand Up @@ -34,34 +35,6 @@ <h1 v-else-if="error != null">載入失敗,請重新整理 :'(</h1>
</div>


<script>

var vm = new Vue({
el: "#container",
data: {
res: null,
loading: true,
error: null
},
components: {
"gank-img": {
props: ['url'],
template: '<img class="gank-img" :src="url">'
}
},
created: async function () {
try {
// 等待獲取回應
let res = await fetch('https://gank.io/api/random/data/福利/20');
// 等待 parse json
this.res = await res.json();
this.loading = false;
} catch (e) {
this.error = e;
}
}
})
;
</script>
<script src="lib/vm.js"></script>
</body>
</html>

0 comments on commit c678552

Please sign in to comment.