Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

watchのサンプルAPIページ #21

Merged
merged 1 commit into from Mar 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/study-vue/public/index.html
Expand Up @@ -18,7 +18,7 @@
</div>

<script src="https://cdn.jsdelivr.net/npm/vue@2.5.13/dist/vue.js"></script>
<script src="main.js?ver=1.3"></script>
<script src="main.js?ver=1.4"></script>
</body>

</html>
4 changes: 4 additions & 0 deletions app/study-vue/public/main.js
Expand Up @@ -26,6 +26,10 @@ var app = new Vue({
href: "sort_list/index.html",
text: "sort_list"
},
watch: {
href: "watch/index.html",
text: "watch"
},
}
}
});
26 changes: 26 additions & 0 deletions app/study-vue/public/watch/index.html
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="ja">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>study-vue</title>
</head>

<body>
<div id="app">
<select v-model="current">
<option v-for="topic in topics" :value="topic.value">
{{ topic.name }}
</option>
</select>
<div v-for="item in list">{{ item.full_name }}</div>
</div>

<script src="https://cdn.jsdelivr.net/npm/vue@2.5.13/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script src="main.js"></script>
</body>

</html>
28 changes: 28 additions & 0 deletions app/study-vue/public/watch/main.js
@@ -0,0 +1,28 @@
var app = new Vue({
el: "#app",
data: {
list: [],
current: '',
topics: [{
value: 'vue',
name: 'Vue.js'
},
{
value: 'jQuery',
name: 'jQuery'
},
]
},
watch: {
current: function (val) {
// GitHubのAPIからトピックのリポジトリを検索
axios.get('https://api.github.com/search/repositories', {
params: {
q: 'topic:' + val
}
}).then(function (response) {
this.list = response.data.items
}.bind(this))
}
}
});