Vue组件的传值问题

组件传值-父传子

父结构

<template>
    父组件
    <com-a :message="msg"></com-a>
</template>
<script>
    export default {
        data () {
            return {
                msg:'父组件数据'
            }
        }
    }
</script>

子结构

<template>
    子组件
    {{message}}
</template>
<script>
    export default {
        props:['message']   
    }
</script>

组件传值-子传父

<template>
  <div id="app">
    父组件
    <com-a @toParent="fn"></com-a>
  </div>
</template>
<script>
import comA from './components/com-a'
export default {
  components: {
    comA
  },
  methods: {
    fn (msg) {
      console.log(msg)
    }
  }
}
</script>
  • 自定义事件给谁绑定的的,谁才能触发

<template>
  <div class="container">
    <p> 子组件A </p>
  </div>
</template>
​
<script>
export default {
  created () {
    this.$emit('toParent', this.msg)
  },
  data () {
    return {
      msg: 'chilren data'
    }
  }
}
</script>

 

09-组件传值-非父子

  • 需要一个vue实例,在组件A和组件B引入,实例是一个公共的实例。

    • 事件给谁绑定,只能谁去调用

eventBus.js

import Vue from 'vue'
export default new Vue({})

com-b

// 绑定一个事件  接收数据
eventBus.$on('toB', (data) => {
    console.log(data)
})

com-a

// 触发自定义事件
eventBus.$emit('toB', 'A组件数据')

注意:先绑定事件,再触发事件。

 

eventBus:

俗:公共汽车,绑定事件和触发事件的公用vue实例。

专业:事件总线,在这个角色去控制所有的事件的绑定和触发。

### S32K3 Microcontroller DMA Configuration Tutorial #### Overview of DMA on the S32K3 Series The Direct Memory Access (DMA) feature within the S32K3 series allows data transfer between memory and peripherals without CPU intervention, improving system efficiency. The eDMA module supports multiple channels with flexible arbitration mechanisms to manage concurrent requests effectively[^1]. #### Key Components Involved in DMA Setup For configuring DMA operations specifically involving ADC interfaces: - **Hardware Units**: Two hardware units can be configured as `ADC0` and `ADC1`. Users should configure these based on their specific circuit requirements[^3]. - **Channel Management**: When using multiple ADC channels, only the last channel triggers a DMA request upon completion. After one major loop finishes executing, it automatically loads the next Transfer Control Descriptor (TCD)[^2]. #### Step-by-step Guide for Configuring DMA with ADC To set up DMA transfers from an ADC peripheral: 1. Initialize the ADC modules (`ADC0`, `ADC1`) according to project needs. 2. Configure TCD settings including source address, destination address, block size, etc., ensuring proper alignment with the desired buffer structure. 3. Set up interrupt handlers if necessary to handle events such as end-of-conversion or error conditions. 4. Enable DMA requests by setting appropriate bits in control registers associated with each ADC instance used. 5. Ensure that after completing a major loop, subsequent minor loops are correctly initialized via preloaded TCD entries. ```c // Example C code snippet showing basic setup steps void init_DMA_for_ADC(void){ // Assuming initialization functions exist for simplicity /* Initialize ADC */ ADC_Init(ADC0); /* Prepare TCD structures */ edma_config_t dmaConfig; EDMA_GetDefaultConfig(&dmaConfig); EDMA_Init(DMA_BASE_ADDR, &dmaConfig); /* Create and configure TCDs */ uint8_t tcdIndex = 0; // Choose available index EDMA_CreateHandle(&g_edmaHandle[tcdIndex], DMA_BASE_ADDR, tcdIndex); } ``` This example demonstrates initializing DMA alongside ADC configurations but does not cover all possible scenarios or optimizations which may vary depending on application specifics. --related questions-- 1. How do different types of DMA modes affect performance when interfacing with ADC? 2. What considerations must be taken into account while designing buffers for storing ADC samples through DMA? 3. Can you explain how priority levels influence DMA operation among competing peripherals like UART vs SPI? 4. In what ways could interrupts play a role during continuous acquisition mode enabled by DMA?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值