首页 > 其他分享 >【首页】文字封装开发

【首页】文字封装开发

时间:2023-01-09 20:34:54浏览次数:42  
标签:文字 index vue 封装 Card 首页 components 组件 card

一、【首页】文字封装开发

1.1 在components/common目录中创建了Card.vue组件文件

1.2 在pages/index/index.vue中引入Card组件

1.3 Card组件是卡片完成效果为复用的文字

1.4 完成效果为:

1.5 Card组件完成代码为:

<template>
	<view class='card'>
		<view>-</view>
		<slot>
			<view class='card-name'>{{cardtitle}}</view>
		</slot>
		<view>-</view>
	</view>
</template>

<script>
	export default{
		props:{
			cardtitle:String
		}
	}
</script>

<style scoped>
	.card{
		padding: 20rpx 0;
		display: flex;
		justify-content: center;
		font-weight: bold;
	}
	.card-name{
		padding: 0 20rpx;
		font-size: 32rpx;
	}
</style>

1.6完成卡片复用主要代码

1.7在pagas/index中调用卡片代码

<template>
	<view class="index">
		<indexswiper></indexswiper>
		<recommend></recommend>
		<card cardtitle='猜你喜欢'></card>
		<card cardtitle='商品店铺'></card>
		<card cardtitle='运动户外'></card>
		<card cardtitle='运动交友'></card>
	</view>
</template>

<script>
	import indexswiper from '@/components/index/indexswiper.vue'
	import recommend from '@/components/index/recommend.vue'
	import card from '@/components/common/card.vue'
	export default {
		data() {
			return {
				
			}
    	},
		components:{
			indexswiper,
			recommend,
			card
		},
		onLoad() {

		},
		methods: {

		}
	}
</script>

<style>

</style>

 

标签:文字,index,vue,封装,Card,首页,components,组件,card
From: https://www.cnblogs.com/liu88/p/17038446.html

相关文章

  • 多项式半家桶,但是未封装
    多项式乘法逆题意:给定\(n-1\)次多项式\(F(x)\),求多项式\(G(x)\),使得\(F(x)G(x)\equiv1\pmod{x^n}\)思路:设:\[F(x)g(x)\equiv1\pmod{x^m}\\\\\F......
  • 【首页】推荐部分开发
    一、【首页】推荐部分开发1.1完成效果图:1.2在components中新建组件Recommend.vue,代码如下:<template> <viewclass='recommendbg-color'> <viewclass='recommend......
  • 那些炫酷的CSS文字效果之诗词《兔》
    不知不觉已经迈入2023年,今年是兔年,想到兔子就会联想到玉兔,中秋,胡萝卜,兔子不吃窝边草,这就越扯越远了,今天的主题是用纯CSS来实现各种不错的文字效果,文字则摘录古诗词中有关《......
  • vue2 element-ui组件二封-表单组件-按钮封装
    这里是一段我们公司过往项目的代码(增删改查项目中的查询/重置按钮)<el-button@click="query()"type="primary"size="mini"><iclass="el-icon-search">查询</i><......
  • 给网站首页置灰(设置黑白背景)
    只要在你的网站全局的部分添加这段css代码就可以实现整站素装了。<style>html{-webkit-filter: grayscale(100%);-moz-filter: grayscale(100%);-ms-......
  • 【首页】swiper部分
    一、【首页】swiper部分1.1  完成效果图:1.2新建IndexSwiper.vue文件,目录结构如图1.3新建IndexSwiper.vue代码如下:<template> <swiper:indicator-dots="true":......
  • 【首页】顶部开发
    三、【首页】顶部开发1.1完成效果图1.2首页顶部需要在pages.json中配置,代码如下:框选中的部分为矢量中unicode代码将&#x改为\u{ "pages":[//pages数组中第一项表......
  • 封装,继承和多态
    1.封装:属性私有,get/set 记住快捷键alt+insert2,继承 extends继承是类和类之间的关系,除此之外,类和类之间的关系还有依赖,组合,聚合等继承关系的两个类,子类(派生类)---父......
  • 封装
    1.我们程序设计追求“高内聚,低耦合”。高内聚就是类的内部数据操作细节自己完成,不允许外部干涉;低耦合:仅暴露少量的方法给外部使用。2.封装(数据的隐藏)通常,应禁止直接......
  • cocos creator教程:框架 - 封装
    【muzzik教程】:框架-封装遇到的问题部分接口/属性不想暴露给外部外部引用方式框架加载方式部分接口/属性不想暴露给外部exportclassprivate_test{ test_b=......