Skip to content

Instantly share code, notes, and snippets.

@h2ospace
Created February 25, 2020 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save h2ospace/78f9aeaf314eeb3481a2bcaf88e9e04d to your computer and use it in GitHub Desktop.
Save h2ospace/78f9aeaf314eeb3481a2bcaf88e9e04d to your computer and use it in GitHub Desktop.
Ajax by Vue.js with jQuery
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="news">
<ul>
<li v-for="item in items">{{ item.title }}</li>
</ul>
</div>
<script src="jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
var app = new Vue({
el: '#news',
data: {
items: {}
},
mounted: function () {
var self = this;
$.getJSON('feed.json', function (json) {
self.items = json.items;
});
}
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment