【Web前端】Vue组件注册、传递和接收参数

1、父组件接收参数(即模板,vue文件)

在<script>标签中添加props属性

组件参数是materials,是对象类型

接收子组件传入的对象

<template>
	<view class="product">
		<image :src="materials.pict_url"></image>
		<span class="product-name">{
  
   
   {materials.title}}</span>
		<span class="coupou-used-price">{
  
   
   {materials.reserve_price}}</span>
		<span class="coupou-used">券后</span>
		<span class="coupou">券</span>
		<span class="coupou-value">{
  
   
   {materials.coupon_amount}}元</span>
		<span class="sale-scale">已售{
  
   
   {materials.volume}}件</span>
	</view>
</template>

<script>
	export default {
		// 组件参数
		props:{
			materials:{
				
			}
		}
	}
</script>

猜你喜欢

转载自blog.csdn.net/Dawson_Ho/article/details/125648613