create Dynamic component and template loading with VueJS

create Dynamic component and template loading with VueJS

Pass the simple component definition to the all the resolve callback method
-This special require all the componet syntax will simple instruct vue Webpack to
-vuejs automatically simple split your built auto code into vue bundles which
-are loaded over Ajax requests.
-Template returned from serve
-Create the new component using the template we received
create Dynamic component and template loading with VueJS Example

change component template dynamically

index.html

[php]

[/php]

READ :  Only One Item Selected - single select between multiple checkbox ul-li

script.js

[php]
new Vue({
el: ‘#app’,
data: {
msg: ‘Welcome – to Pakainfo.com !! Good Luck’,
template: null
},
render: function(createElement) {
if (!this.template) {
return createElement(‘span’, ‘Loading…’);
} else {
return this.template();
}
},
mounted() {
var mydata = this;
setTimeout(function() {
mydata.template = Vue.compile(‘{{ msg }}‘).render;
}, 1000);
}
})

[/php]

Example

Creating a Dynamic Component

Dynamic components in Vuejs simple allow you to specify version a single data model mounting point to point where you could dynamically data switch between simple components in we web application.

We will start apps off by making a dynamic simple component and exploring all the keep-alive session parameter, and simple finally applying and init mode some transitions to our dynemically components as the user switches simple between them.

READ :  Angular Introduction and Hello World Tutorial

[php]
Vue.component(‘async-live24’, function (resolve, reject) {
setTimeout(function () {
resolve({
template: ‘

I am simple async Componet!


})
}, 1500)
})

Vue.component(‘async-webpack-live24’, function (resolve) {

require([‘./new-async-component’], resolve)
})
Vue.component(
‘async-webpack-live24’,
() => import(‘./new-async-component’)
)

[/php]

We are Web Technology Experts and Team who provide you very Important information on Web Development information, Interview Questions and Answers, live project problem solution and their solution and online free tutorials – infinityknow.com”.

Example

Leave a Comment