路由文件

{
path: '/productListBase', name: 'productListLink', component: ProductListBase, redirect: '/productList', children: [
{
path: '/productList',
components: {
default: Banner,
product_list: ProductList
}
}
]
},

这个是中间文件(也就是父级)

<template>
<div class="product">
<router-view :aaa="aaa"></router-view>
<router-view name="product_list"></router-view>
</div>
</template> <script>
export default {
data(){
return {
aaa:{
name_en:'PRODUCT',
name_zh:'MIRROR产品'
}
}
}
}
</script>

在父级设置参数,如果是aaa='aaa',此时传的是aaa的字符串,而:aaa="aaa"传的是对象(或数组)

在子页面接收参数

export default {
props:['aaa'],
computed:{
my(){
this.banner = this.aaa
console.log(this.aaa,'aaa')
}
},
}

通过 props 来接收父级传过来的参数,然后在 使用computed属性将收到的值赋给当前组件的data中的banner。

最后要记得在子页面中调用 my() 方法

<template>
<div>
{{my}}
</div>
</template>

子组件向父组件传值

子组件

this.$emit("changes",);

父组件

<searchH ref="searchH" @changes="aaa()"></searchH>

methods:{
aaa(e){
console.log(e)
}
}

每天一点点之vue框架开发 - vue组件之间传值(父向子传值)的更多相关文章

  1. 每天一点点之vue框架开发 - vue坑-This relative module was not found

    94% asset optimization ERROR Failed to compile with 1 errors This relative module was not found: * . ...

  2. 每天一点点之vue框架开发 - vue坑-input 的checked渲染问题

    选中radio或者checkbox需要注意的是: 不管<input type='radio checked='true''>  你的checked属性值是true或者false,他都会选中 ...

  3. 每天一点点之vue框架开发 - vue 动态替换路由(地址栏)参数

    import merge from 'webpack-merge': // 修改原有参数 this.$router.push({ query:merge(this.$route.query,{'max ...

  4. 每天一点点之vue框架开发 - vue中使用vue-router切换页面时自动滚动到顶部的方法

    1. 在main.js入口文件中写入 //路由跳转后,页面回到顶部 router.afterEach(() => { document.body.scrollTop = 0; document. ...

  5. 每天一点点之vue框架开发 - 引入Jquery

    1. 安装jquery npm install jquery --save-dev 2.在build/webpack.base.conf.js中添加如下内容 var webpack = require ...

  6. 每天一点点之vue框架开发 - 使用vue-router路由

    1.安装路由(安装过的跳过此步) // 进入项目根目录 cd frontend // 安装 npm install vue-router --save-dev 2.在入口文件main.js中引入路由 ...

  7. Vue 框架-09-初识组件的应用

    Vue 框架-09-初识组件的应用 今天的第一个小实例,初步使用组件: 在 app.js 中定义模板组件,在 html 文件中使用自定义标签来显示 js 文件中定义的 html 代码块 比如说,下面定 ...

  8. Vue框架:vue-cookies组件

    目录 一.vue-cookies简介 二.vue-cookies安装与配置 三.vue-cookies的使用 一.vue-cookies简介 vue-cookies组件是vue框架用来操作浏览器coo ...

  9. Vue其他指令-组件-全局-局部-组件的交互父传子

    v-once指令 once:一旦,当...时候 <!DOCTYPE html> <html lang="zh"> <head> <meta ...

随机推荐

  1. 替换django的user模型出现的异常django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applied before its dependency users.0001_initial on database 'default'

    django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applie ...

  2. JDBC Connection Configuration配置正确,提示Error preloading the connection pool

    JDBC Connection Configuration配置正确,提示Error preloading the connection pool JDBC 请求报错,提示: 因为之前执行是正确的,这次 ...

  3. redis的基本操作

    redis是key-value的数据结构,每条数据都是⼀个键值对 键的类型是字符串 注意:键不能重复 值的类型分为五种: 字符串string 哈希hash 列表list 集合set 有序集合zset ...

  4. python-python基础6(面向对象)

    一.面向对象编程 编程范式 编程是 程序 员 用特定的语法+数据结构+算法组成的代码来告诉计算机如何执行任务的过程 , 一个程序是程序员为了得到一个任务结果而编写的一组指令的集合,正所谓条条大路通罗马 ...

  5. 智能充电安全管理首选SOC单芯片方案:SI24R2F

    SI24R2F简介:       SI24R2F是一颗工作在2.45GHZ ISM 频段,专为低功耗有源RFID应用场合设计,集成崁入式2.45GHZ 无线射频发射器模块.64次可编程NVM存储器模块 ...

  6. jenkins#安装gitlab

    通过docker安装gitlab 参考 ------------------------------ 拉docker 镜像: docker pull gitlab/gitlab-ce 创建目录存储gi ...

  7. BFPRT(中位数的中位数算法)

    BFPRT(中位数的中位数算法) 类似于快排,但是划分区间的策略不一样. 分组,组内排序: 取出每组的中位数组成一个数组,再取这个数组的中位数: 以取出的中位数作为partition的轴.

  8. Netty简单认识

    简介 Netty 是由JBOSS提供的一个 Java开源框架, 现在是 Github上的开源项目 Netty 是一个异步的.基于事件驱动的网络应用框架式, 用以快速开发高性能.高可靠性的网路IO程序 ...

  9. 吴裕雄 Bootstrap 前端框架开发——Bootstrap 字体图标(Glyphicons):glyphicon glyphicon-repeat

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name ...

  10. JuJu团队12月1号工作汇报

    JuJu团队12月1号工作汇报 JuJu   Scrum 团队成员 今日工作 剩余任务 困难 于达  修改generator函数  优化代码  不熟悉julia 婷婷 和金华一起调试main.jl 继 ...