Home > front end >  Questions about the Quasar framework dynamic load components
Questions about the Quasar framework dynamic load components

Time:02-06

Consult everybody, I have a page nested a component, the way I want to by an external reference dynamic load of different components,

Components: {
Showform: ()=& gt; Import (' components/form/+ String (this. $route. Params. Processid) + 'vue')
},

But found so write words, compile time server will always jammed, the front desk page has also been loading,

Ask what is the place to write wrong? And what better way?

CodePudding user response:

The problem of this pointer

To the top in the script first define variables var _that=null;
Components: {
Custom: ()=& gt; Import (`./component/${_that. Name} `)
},

Second created to _that inside this vue of an assignment for the current instance

CodePudding user response:

Is this change? If not yet
<script>
Var FormComponentName=null
Export the default {
Data () {
Return {
TAB: 'showform',
Title: null
}
},
Components: {
Showform: ()=& gt; Import (` components/form/${FormComponentName. $route. Params. Processid}. Vue `),
},
Created: the function () {
FormComponentName=this
}
}
</script>
  • Related