国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

javascript - Why does vue fail to use component dynamic components?
僅有的幸福
僅有的幸福 2017-05-31 10:39:56
0
2
932

1. Why using component to dynamically add components failed?

<template>

<component @showHide="recieveAddData" :is="addModal"
 ></component>
 <button @click="switchComponent"></button>

</template>
import modal from './company/modal.vue'
export default {

name: 'addItem',
data () {
  addModal: 'modal'
},
methods: {
  switchComponent () {
   this.addModal = 'first'
},
components: {
  modal,
  first: {
     template: "<p>這里是子組件3</p>"  
  }
}

}

Why can the first component be added dynamically, but why can’t the introduced modal component work?

僅有的幸福
僅有的幸福

reply all(2)
PHPzhong

Isn’t modal the first component?
The modal cannot be loaded when mounted.
After clicking the button, the first component can be loaded instead?

One more thing.
The correct way to write data is to return an object

data() {
    return {}
}
黃舟
import modal from './company/modal.vue';
export default {

name: 'addItem',
methods: {
  switchComponent () {
   this.addModal = 'first'
},
computed:{
    addmodal:modal 
},
components: {
  first: {
     template: "<p>這里是子組件3</p>"  
  }
}
}

Remove the modal in components and write the value of addModal as modal instead of 'modal';

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template