Recently delving into Vue.js, I am eager to set up a basic website using it. Each page (About Us, Contact Us, etc) has its corresponding component.
Here is my functional starting point
Vue.component('about-us', {
template: '<div>...lots of markup...</div>'
});
My goal is to transition this code to work asynchronously. Following the documentation, I have attempted the following code:
Vue.component('about-us', function(resolve, reject){
let template_string = '';
// Load the template with ajax
$.post(ajax_url, {'action': 'get_about_page'}, function(r){
r = JSON.parse(r);
// Save the template string
if( r.success ) {
template_string = r.data;
}
});
// Resolve callback for Vue
resolve({
template: template_string
});
});
The error message I am encountering is:
[Vue warn]: Failed to mount component: template or render function not defined. found in ---> Anonymous Root
Question: Am I approaching this incorrectly? Is it a syntax issue? I am uncertain if I am on the right track. (Yes, I have jQuery loaded)