bouquins-bchs/book.js

28 lines
669 B
JavaScript
Raw Normal View History

2016-12-31 11:01:38 +00:00
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();
}
})