Last active
March 25, 2020 01:26
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=== 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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Really? Vue and jQuery. Missing Mootools and React