1👍
Use vue-router’s data hook.
http://router.vuejs.org/en/pipeline/data.html
route: {
data: function (transition) {
return this.$http.get(...);
}
}
Then, in the template:
<div v-if="$loadingRouteData">Loading ...</div>
<div v-else>Your current HTML.</div>
1👍
A simple fix is to prevent Vue from trying to access the object property:.
First set the initial content
value to null
, based on your example, there is no reason to set is as an empty array. Looks like it will get assigned an object from your response data. Then, in your view, just do this:
{{{ content ? content.content.rendered : null }}}
- [Vuejs]-Vue.js: How to read $index inside computed function?
- [Vuejs]-Adding together multiple number inputs using Vue.js
Source:stackexchange.com