bouquins-bchs/book.js
2016-12-31 12:17:01 +01:00

28 lines
669 B
JavaScript

var app = new Vue({
el: '#app',
data: {
urlParams: {},
book: {}
},
methods: {
urlParse: function() {
var match,
pl = /\+/g, // Regex for replacing addition symbol with a space
search = /([^&=]+)=?([^&]*)/g,
decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
query = window.location.search.substring(1);
while (match = search.exec(query))
this.urlParams[decode(match[1])] = decode(match[2]);
},
loadBook: function() {
console.log(this.urlParams.id);
}
},
created: function() {
this.urlParse();
},
mounted: function() {
this.loadBook();
}
})