請教各位,我有一張頁面嵌套了一個組件,我想通過外部傳參的方式動態的加載不同的組件。
components: {
showform: () => import('components/form/' + String(this.$route.params.processid) + '.vue')
},
但發現這樣寫的話,編譯時服務器會一直卡死,前臺頁面也一直loading。
請教有什么地方寫的不對?或者有什么更好的方法?
uj5u.com熱心網友回復:
this指標的問題先在script最上面定義變數 var _that = null;
components: {
Custom: () => import(`./component/${_that.name}`)
},
其次created里面給_that賦值為當前的vue實體this
uj5u.com熱心網友回復:
是這樣改嗎?好像還不行<script>
var FormComponentName = null
export default {
data () {
return {
tab: 'showform',
title: null
}
},
components: {
showform: () => import(`components/form/${FormComponentName.$route.params.processid}.vue`),
},
created: function () {
FormComponentName = this
}
}
</script>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/256984.html
標籤:JavaScript
上一篇:web呼叫本地exe程式傳引數
