vue is

is 用法

 <ul>
  <li is='my-component'></li>  //自己写的组件
</ul>
<!-- 组件会在 `件名` 改变时改变 -->
<component :is="组件名变量"></component>

使用第二种方法

在这里插入图片描述

未使用 is 代码

<a-tabs
  @change="tabCallback"
  :animated="false"
  :activeKey="inTabIndex"
  class="height-100"
  style="text-align: left;"
>
<a-tab-pane tab="我的题卷库" key="1">
  <my-topic-volume>
    <select-question-type slot="selectQuestionType" :tabIndex="inTabIndex" :selectType="selectType"
                          @queryQuestionByConditions="queryQuestionByConditions"
    ></select-question-type>
    <question-content slot="questionContent" :selectType="selectType"></question-content>
  </my-topic-volume>
</a-tab-pane>
<a-tab-pane tab="校本题卷库" key="2">
  <school-topic-volume>
    <select-question-type slot="selectQuestionType" :tabIndex="inTabIndex" :selectType="selectType"
                          @queryQuestionByConditions="queryQuestionByConditions"
    ></select-question-type>
    <question-content slot="questionContent" :selectType="selectType"></question-content>
  </school-topic-volume>
</a-tab-pane>
</a-tabs>

使用 is 后的代码

data(){
    return{
          aTabPaneList: [{tab: "我的题卷库", key: "1"}, {tab: "校本题卷库", key: "2"}],
          isComponent: MyTopicVolume,
         }
      }
methods : {
      tabCallback(val) {
          this.inTabIndex = val;
          if (val == 1) {
            this.isComponent = MyTopicVolume;
            } else if (val == 2) {
           this.isComponent = SchoolTopicVolume;
           }
      },
}
<a-tabs
  @change="tabCallback"
  :animated="false"
  :activeKey="inTabIndex"
  class="height-100"
  style="text-align: left;"
>
<a-tab-pane :tab="item.tab" :key="item.key" v-for="item of aTabPaneList">
  <component :is="isComponent">
    <select-question-type slot="selectQuestionType" :tabIndex="inTabIndex" :selectType="selectType"
                          @queryQuestionByConditions="queryQuestionByConditions"
    ></select-question-type>
    <question-content slot="questionContent" :selectType="selectType"></question-content>
  </component>
</a-tab-pane>
</a-tabs>

完美~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值