zoukankan      html  css  js  c++  java
  • Vue 全局组件传递参数

    1.在components文件下创建相关组件如(breadcrumb.vue)

    <template>
    <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
    <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
    <el-breadcrumb-item>{{breadName}}</el-breadcrumb-item>
    <el-breadcrumb-item>{{breadValue}}</el-breadcrumb-item>
    </el-breadcrumb>
    </div>

    </template>

    <script>
    export default {
    name: 'breadcrumb',
    props: {
    breadName: {
    // 规定传值为字符串 默认的名字
    type: String,
    default: '默认的name'
    },
    breadValue: {
    type: String,
    default: '默认的value'
    }
    }
    }
    </script>

    <style scoped>

    </style>

    2.main文件 全局注册

    import Bread from './components/breadcrumb/breadcrumb.vue'
    Vue.component('Bread', Bread)
    

    3.使用全局组件

    <template>
    <div>
      <!--    面包屑东导区域-->
     <Bread :breadName="'999'" :breadValue="'666'"></Bread>
    
    </div>
    </template>
    
    <script>
    export default {
      name: 'Rights'
    }
    </script>
    
    <style scoped>
    
    </style>
  • 相关阅读:
    51Nod 1239 欧拉函数之和
    51Nod 1244 莫比乌斯函数之和
    BZOJ 4805: 欧拉函数求和
    BZOJ 3944: Sum
    3.25阅读摘抄
    生活整洁之道
    1064. 朋友数(20)
    1063. 计算谱半径(20)
    1061. 判断题(15)
    1062. 最简分数(20)
  • 原文地址:https://www.cnblogs.com/WorldEye/p/13985179.html
Copyright © 2011-2022 走看看