当前位置: 首页> 财经> 股票 > 网站建设包括哪些方面_智博常州网站建设_seo优化的网站_百度小说排行榜风云榜

网站建设包括哪些方面_智博常州网站建设_seo优化的网站_百度小说排行榜风云榜

时间:2025/7/19 5:16:37来源:https://blog.csdn.net/Jsjendndn/article/details/143314784 浏览次数:0次
网站建设包括哪些方面_智博常州网站建设_seo优化的网站_百度小说排行榜风云榜

父传子

下面是子组件

<template>
<h1>{{ count }}</h1>
</template>
<script>
expose default {name:'HelloWorld',props: {count:{type:[String,Number],default:"100"}    }
}</script>

子组件使用Props发送

父组件接收:

<template>
<div id = "app"><HelloWorld count = 100></HelloWorld>
</div>
</template><script>import HelloWorld from './components/HelloWorld.vue'export default {name: 'App',components: {HelloWorld},}
}
</script>

子传父

eg:每个商品选中后,把价钱传给父组件,然后结算。

<template>
<h1>{{ count }}</h1>
<button @click="handler">按钮</button>
</template>
<script>
expose default {name:'HelloWorld',props: {count:{type:[String,Number],default:"100"}    },data () {return {childCount: 0}},methods: {handler () {this.childCount++,this.$emit('child-count-change',this.childCount)}}
}</script>

父组件:

<template>
<div id = "app"><HelloWorld count = 100,@child-count-change="handler"></HelloWorld><h1>{{ childData }}</h1>
</div>
</template><script>import HelloWorld from './components/HelloWorld.vue'export default {name: 'App',components: {HelloWorld},data () {childData: 0}methods: {handler (childCount) {this.childData = childCount}}}</script>

关键字:网站建设包括哪些方面_智博常州网站建设_seo优化的网站_百度小说排行榜风云榜

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: