Skip to content

Instantly share code, notes, and snippets.

@ITSecMedia
Last active March 25, 2020 01:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save ITSecMedia/f008f2ccb692277dfc12e6853e8da6fb to your computer and use it in GitHub Desktop.
Save ITSecMedia/f008f2ccb692277dfc12e6853e8da6fb to your computer and use it in GitHub Desktop.
simple vue.js 2.0 example to add dynamic values in gohugo.io static websites.
=== rest.php ===
some php that creates html output
=== put in your app.js ===
$( document ).ready(function() {
var url_api = 'http://www.domain.com/api/rest.php';
var header = new Vue({
delimiters: ['((', '))'],
el: '#api',
data: {
message: '...'
},
created: function () {
this.fetchData();
},
methods: {
fetchData: function () {
var self = this;
$.get( url_api, function( data ) {
self.message = data;
// console.log(data);
});
}
}
})
});
=== inside your hugo layout ===
<script type="text/javascript" src="{{ "js/vue.min.js" | absURL }}"></script>
<div id="api">
<div v-html="message"></div>
</div>
@magic-77
Copy link

Really? Vue and jQuery. Missing Mootools and React

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment