zoukankan      html  css  js  c++  java
  • Vue引入其他组件的部分内容

    Vue引入其他组件的部分内容

    在想要引入某一组件内容的页面绑定一个状态值

    <template>
        <div>
        <com-main :state="true"></com-main>
        <div>
    <template>
    
    <script>
    import comMain from '@/views/home/components/index/index.vue'
    
    export default {
        components:{
        'com-main':comMain
      }
    }
    </script>

    在组件中用props接收状态值    此时组件中h2的内容就会被引入上面的页面中

    <template>
      <div>
        <h1 v-if="!state">我是麦兜儿</h1>
        <h2>我是麦麦兜兜儿</h2>
      </div>
    </template>
    
    <script>
    export default {
      props:{
        state:{
          type:Boolean
        }
      }
    }
    </script>
  • 相关阅读:
    22-Camping野营-露营
    node留言板
    js中const,var,let区别
    app消息推送
    Vue + Mui
    七牛云图片存储---Java
    springboot---发送邮件
    SSM简易版
    Hibernate---快速入门
    Vue---mock.js 使用
  • 原文地址:https://www.cnblogs.com/Maipocket-y/p/13408842.html
Copyright © 2011-2022 走看看