vue子组件与子组件之前传值-----最简单办法
1.在main.js中定义一个值(红色为重点)
new Vue({ el: '#app', data: { Bus: new Vue() }, router, store, render: h => h(App) })
2.在components/EditOrder.vue组件中点击按钮传值
<template> <div class="analysis" @click="analysis">点击</div> </template> <script> export default { methods: { analysis() { this.$root.Bus.$emit('analysisClick', true) } } } </script>
3.components/analysisAddress.vue中接收EditOrder组件传值
<script> export default { mounted() { const that = this this.$root.Bus.$on('analysisClick', function (msg) { that.addressAnalysis = msg }) } </script>
好啦,大功告成,是不是很简单的样子