Welcome aboard! We are happy you are here and wish you good net-raft!
<html>
<head>
<title>VueJs</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.8/vue.min.js"></script>
<script src="https://cdn.jsdelivr.net/vue.resource/1.0.3/vue-resource.min.js"></script>
<body>
<div id="app" v-cloak>
<ul>
<li v-for="post in posts">
{{ post.loc }}
</li>
</ul>
</div>
<script type = "text/javascript">
var app = new Vue({
el: '#app',
data: {
posts: []
},
mounted: function() {
var vm = this
this.$http.get('https://ipinfo.io/')
.then(function(response) {
vm.posts = response
})
}
})
</script>
</body>
</html>
<html>
<head>
<title>VueJs</title>
<script type = "text/javascript" src = "https://cdnjs.cloudflare.com/ajax/libs/vue/2.4.0/vue.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
</head>
<body>
<div id = "app">
lat:<h1>{{ json.latitude }}</h1> long:<h1>{{ json.longitude }}</h1>
</div>
<script type = "text/javascript">
new Vue({
el: '#app',
data: {
json: null
},
created: function () {
var _this = this;
$.getJSON('https://geoip-db.com/json/', function (json) {
_this.json = json;
});
}
});
</script>
</body>
</html>
The most helpful VUE.JS solutions
get ip address using vuejsVUE.JS Click to see more ... 9.7K 76