当前位置: 首页 > wzjs >正文

jsp做网站好不好国外b站浏览器

jsp做网站好不好,国外b站浏览器,网页美工技能培训,视频号直播推广二维码目录 一、基本概述二、基本使用三、插槽 一、基本概述 在项目的开发过程中,页面上井场会出现一些通用的内容,例如头部的导航栏,如果我们每一个页面都去写一遍,那实在是太繁琐了,所以,我们使用组件来解决这…

目录

  • 一、基本概述
  • 二、基本使用
  • 三、插槽


一、基本概述

在项目的开发过程中,页面上井场会出现一些通用的内容,例如头部的导航栏,如果我们每一个页面都去写一遍,那实在是太繁琐了,所以,我们使用组件来解决这一难题。

二、基本使用

下面的案例中,我们定义一个用户信息展示的组件,通过传递一个对象来展示用户的头像以及姓名。
在这里插入图片描述
首先我们需要定义一个用户信息展示的组件user-info,uniapp中定义组件需要定义在根目录下的components中

<template><view class="box"><image :src="userImage" mode="aspectFill" class="user-image"></image><view class="user-name">{{userName}}</view></view>
</template><script setup>
import { computed } from 'vue';const props = defineProps({userName: {type: String, default: "匿名"},userImage: {type: String, default: "../../../static/logo.png"},obj: {type: Object, default() {return {userName: "匿名", userImage: "../../../static/logo.png"}}}
})
const userNameT = computed(() => props.userName + "@")
</script><style lang="scss" scoped>
.box {margin: 5rpx;width: 100%;height: 250rpx;background-color: #ccc;display: flex;flex-direction: column;align-items: center;justify-content: center;.user-image {width: 200rpx;height: 200rpx;}.user-name {margin-top: 5rpx;width: 100%;text-align: center;font-size: 14rpx;}
}
</style>

在主页面调用组件,uniapp会自动检索components下面的组件,所以在页面中不需要引入

<template><view class="box"><page-head title="component 组件"></page-head><view class="uni-padding-wrap uni-common-mt uni-flex uni-row uni-container"><user-info v-for="item in userList" :user-name="item.userName" :user-image="item.userImage"></user-info></view></view>
</template><script setup>
import { ref } from 'vue';const userList = ref([{userName: "张三", userImage: "../../../static/logo.png"},{userName: "李四", userImage: "../../../static/java.jpeg"},{userName: "王五", userImage: "../../../static/mybatis.png"},{userName: "赵六", userImage: "../../../static/mysql.jpeg"},
])
</script><style lang="scss" scoped>.uni-container {-webkit-flex-wrap: wrap;flex-wrap: wrap;}
</style>

三、插槽

我们在定义组件的时候,有的时候个别部分是不通用的,如果都单独创建一个特定的组件,那将会失去组件的真实意义,因此,vue为我们提供了slot插槽标签帮我们解决了这一问题,将单独部分进行定制。
在这里插入图片描述
首先我们需要定义一个标题组件,在特定的区域,我们使用slot插槽进行留白。

<template><view class="box"><view class="box-title-t">{{title}}</view><view><slot name="icon"></slot></view></view>
</template><script setup>
const props = defineProps({title: {type: String, default: "这是啥?"}
})</script><style lang="scss" scoped>
.box {padding: 0 10rpx;width: 100%;height: 100rpx;display: flex;flex-direction: row;align-items: center;justify-content: space-between;.box-title-t {color: #000;font-weight: 700;}
}
</style>

在主页面中我们引入组件,并对组件进行定制,这里需要注意的是,插槽里面的样式要写在主页面中,如果写在组件里面,那会成为公共样式。

<template><view class="box"><page-head title="component 组件"></page-head><view class="uni-padding-wrap uni-common-mt uni-flex uni-row uni-container"><title-info title="精彩呈现" class="title-class"><template #icon><image src="/static/logo.png" mode="aspectFill"></image></template></title-info><title-info title="其他内容" class="title-class"><template #icon><text>More+</text></template></title-info></view></view>
</template><script setup></script><style lang="scss" scoped>.title-class {image {width: 50rpx;height: 50rpx;}text{color: #ccc;}}
</style>
http://www.dtcms.com/wzjs/201421.html

相关文章:

  • 邳州城乡建设局网站google官方下载app
  • 闵行12路网站seo入门基础教程书籍
  • 关于网站建设的问卷调查网络优化工程师为什么都说坑人
  • 网站建立定位企划全国疫情最新情况公布
  • wordpress title description资阳市网站seo
  • 德阳做网站的公司黄冈网站推广软件
  • 韩国家具网站模板百度极速版客服电话
  • 巴顿品牌设计公司广西百度seo
  • 如何做网站可以吗公司企业网站建设方案
  • 河南省建设厅一体化平台关闭站长工具seo综合查询
  • 做暧昧的小视频网站2竞价 推广
  • 免费个人网站注册有广告位怎么找广告商
  • wordpress 站内信插件快速排名提升
  • 装备可以卖人民币的手游网站的优化
  • 北京做百度网站建设有哪些网络营销公司
  • 定制型网站建设服务器网络推广工作好吗
  • 企业网站建设代理日本搜索引擎
  • 泉州网站建设哪里优惠济南网站建设老威
  • 做网站需注重的几点电子商务网站有哪些?
  • 自己做淘宝客是不是需要建网站淮北网站建设
  • 做网站的联系方式优化百度搜索
  • 杨凌区住房和城乡建设局网站日本网站源码
  • 阳谷网站建设费用seo广告平台
  • 有域名和主机怎么做网站seo服务外包费用
  • 网站做下CDN防护关键词优化seo费用
  • 做外贸独立网站 但是产品不行品牌营销策略四种类型
  • 番禺电子商务网站建设b2b外贸平台
  • 企查查企业信息查询网丽水网站seo
  • 合肥 网站建设网站推广名词解释
  • wordpress 4.2.20百度seo排名培训