需要注意的是main.js里面需要取消vue-router的默认路由,src/main.js的router.replace('/goods');需要去掉

原因是在添加了其他页面(原来路由只有一个页面goods,现在多了页面ratings)之后,在浏览器加载页面的时候:

首先会先加载所有页面

在各个页面都在加载的过程中,会跳到默认路由

然后这些页面被中断了加载,导致了页面内部的一些靠dom渲染的代码无法执行,例如bs-scroll

所以会出现一些报错,TypeError: Cannot read property 'children' of undefined

所以要做默认路由的时候,直接用url做,不用vue-router自己去跳转,直接写第一个url的地址

主体框架

需要加一个ref,为了让bscroll可以初始化dom

ratings内容

html代码

{{seller.score}}

综合评分
高于周边商家{{seller.rankRate}}%

服务态度

{{seller.serviceScore}}

商品评分

{{seller.foodScore}}

送达时间

{{seller.deliveryTime}}分钟

三个一样的模块共用一套样式代码,分别代入不同的数据

这里的数据都是获取seller的数据,是父组件传入的props

js代码

import star from '../star/star';

export default {

props: {

seller: {

type: Object

}

},

components: {

star

}

};

css代码

.ratings

position: absolute

top: 174px //留空一部分,给header使用

bottom: 0

left: 0

width: 100%

overflow: hidden

.overview

display: flex

padding: 18px 0

.overview-left

flex: 0 0 137px //flex布局,固定左边,右边自动适配

padding: 6px 0

width: 137px

border-right: 1px solid rgba(7, 17, 27, 0.1)

text-align: center

@media only screen and (max-width: 320px) //适配i5屏幕

flex: 0 0 120px //适配的flex数值可以从根据设计稿计算

width: 120px

.score

margin-bottom: 6px

line-height: 28px

font-size: 24px

color: rgb(255, 153, 0)

.title

margin-bottom: 8px

line-height: 12px

font-size: 12px

color: rgb(7, 17, 27)

.rank

line-height: 10px

font-size: 10px

color: rgb(147, 153, 159)

.overview-right

flex: 1 //flex布局,固定左边,右边自动适配

padding: 6px 0 6px 24px

@media only screen and (max-width: 320px) //适配i5屏幕

padding-left: 6px

.score-wrapper //三个一样的模块的共用样式

margin-bottom: 8px

font-size: 0

.title

display: inline-block

line-height: 18px //针对模块内部的元素的对齐行,所以需要写到内部元素里面去

vertical-align: top

font-size: 12px

color: rgb(7, 17, 27)

.star

display: inline-block

margin: 0 12px

vertical-align: top

.score

display: inline-block

line-height: 18px

vertical-align: top

font-size: 12px

color: rgb(255, 153, 0)

.delivery-wrapper

font-size: 0

.title

line-height: 18px

font-size: 12px

color: rgb(7, 17, 27)

.delivery

margin-left: 12px

font-size: 12px

color: rgb(147, 153, 159)

关于适配iphone5,因为设计稿是以iphone6为模板设计的,如果不适配一些小的屏幕的话,对于一些比较宽的div(例如overview-left,overview-right)就会出现换行,被挤压的显示清空,所以需要使用media query来做一些基本的适配,这里只是以iphone5为适配参考,具体做法就是针对不同的屏幕宽度做处理

ratingselect组件

html代码

:ratings="ratings">

ratings列表

html代码

  • {{rating.username}}

    {{rating.deliveryTime}}

    {{rating.text}}

    {{item}}

    {{rating.rateTime | formatDate}}

需要注意recommend的布局处理

needShow和过滤时间类似food.vue组件里面使用九.商品详情页food.vue

js代码

import BScroll from 'better-scroll';

import { formatDate } from '../../common/js/date'; //相对路径导入

import star from '../star/star';

const ALL = 2; //设置常量,比较好的代码风格,代替直接写数字到代码里面去

const ERR_OK = 0;

export default {

props: {

seller: {

type: Object

}

},

data() {

return {

ratings: []

};

},

created() { //初始化数据,从api那里获取

this.$http.get('/api/ratings').then((response) => {

response = response.body;

if (response.errno === ERR_OK) {

this.ratings = response.data;

this.$nextTick(() => { //异步初始化滚动

this.scroll = new BScroll(this.$refs.ratings, {

click: true

});

});

}

});

},

methods: {

needShow(type, text) { //控制显示是否有内容的rate

if (this.onlyContent && !text) {

return false;

}

if (this.selectType === ALL) {

return true;

} else {

return type === this.selectType;

}

}

},

filters: { //过滤时间

formatDate(time) {

let date = new Date(time);

return formatDate(date, 'yyyy-MM-dd hh:mm');

}

},

components: {

star

}

};

css代码

@import "../../common/stylus/mixin.styl"

.rating-wrapper

padding: 0 18px

.rating-item

display: flex //使用flex布局

padding: 18px 0

border-1px(rgba(7, 17, 27, 0.1))

.avatar

flex: 0 0 28px //使用flex布局

width: 28px

margin-right: 12px

img

border-radius: 50%

.content

position: relative //重新定义相对布局的参考父div,被内部元素做绝对布局使用

flex: 1 //使用flex布局

.name

margin-bottom: 4px

line-height: 12px

font-size: 10px

color: rgb(7, 17, 27)

.star-wrapper

margin-bottom: 6px

font-size: 0

.star

display: inline-block

margin-right: 6px

vertical-align: top

.delivery

display: inline-block

vertical-align: top

line-height: 12px

font-size: 10px

color: rgb(147, 153, 159)

.text

margin-bottom: 8px

line-height: 18px

color: rgb(7, 17, 27)

font-size: 12px

.recommend

line-height: 16px

font-size: 0

.icon-thumb_up, .item //共有属性

display: inline-block

margin: 0 8px 4px 0 //分配右外边距和下外边距

font-size: 9px

.icon-thumb_up //个别属性,因为icon没有颜色,需要配置

color: rgb(0, 160, 220)

.item //个别属性

padding: 0 6px //设置左右内边距,撑开布局,形成类似button的效果

border: 1px solid rgba(7, 17, 27, 0.1)

border-radius: 1px

color: rgb(147, 153, 159)

background: #fff

.time

position: absolute

top: 0

right: 0

line-height: 12px

font-size: 10px

color: rgb(147, 153, 159)

这里的flex布局是左边固定28px,然后右边占满剩下的空间

flex: 0 0 28px 是flex-grow为0(项目不放大比例),flex-shrink为0(项目不缩小比例),flex-basis为28px(固定占用28px)

flex: 1是flex 1 1 auto的缩写,就是会放大项目比例,并且剩余的项目空间也占有

参考:Flex 布局教程:语法篇

针对recommend的布局:

每一个内容都是一个span,span是行内元素,可以并列一行

设置外边距是为了span之间能够形成独立的间隙

设置内边距是为了让span和文字形成button的效果

html 价格列表组件,评价列表ratings组件相关推荐

  1. vue外卖二十:商家详情-评价列表:评价列表接口模拟-vuex获取完整数据链流程、滑动better-scroll

    一.评价列表接口模拟-获取完整数据链流程 1)数据模拟mockjs src/mock/mockServer.js /* 使用mockjs提供mock数据接口*/ import Mock from 'm ...

  2. iview 下拉select样式_iview的select组件的列表样式和点击都无效

    iview的select组件用按需引入的方式加载这个组件之后列表样式和点击都无效,但是在main.js全局引入iview之后再用这个select组件又没有这个问题,main.js里面只引入了样式文件, ...

  3. Feathers组件--之--列表

    文章转自:点击打开链接 自定义 列表内容 [参考] 1 List组件用法 http://www.starlinglib.com/wiki/Feathers:list [ENGLISH] http:// ...

  4. uniapp实现组件化列表开发

    在使用uniapp开发的时候我们经常需要使用到组件化开发,这样可以减少代码的冗余,今天我来分享一下我的组件化列表开发 创建目录-MyUniapp-components-modeItem-index.v ...

  5. 列表中滚动鼠标Tooltip文本提示组件在列表中出现错位问题优化、elememt库的组件;

    项目问题:为了展示隐藏标题全部的文本内容,通过引入el-element组件tooltip 文本提示组件:需求是列表中的标题,当列表展示条数超出规范区域长度时添加了隐藏滚轮效果.当鼠标点击标题提示too ...

  6. 微信小程序 scroll-view组件实现列表页实例代码

    这篇文章主要介绍了微信小程序 scroll-view组件实现列表页实例代码的相关资料,scroll-view组件介绍scroll-view是微信小程序提供的可滚动视图组件,其主要作用是可以用来做手机端 ...

  7. Vue.js仿饿了么外卖App--(5)评价列表页实现

    文章目录 一.内容介绍 1.内容 2.效果 二.具体实现 1.数据的获取 2.具体布局 3.star组件 4.ratingSelect组件 三.源码 一.内容介绍 1.内容 本篇文章主要介绍的是评价列 ...

  8. vue外卖二十一:商家详情-评价列表-条件过滤显示评价:只显示好评/差评+显示只带内容评价、用getters生成好评数量新状态

    一.基本数据标识设计shop/ratings/ratings.vue 1)data数据设计 data(){return{showText:true, //条件1:只显示带文字的评价ratingType ...

  9. 星级评价组件--引发对React组件的思考

    机缘巧合之下,我在接到我司产品星级评价需求的前一天,看到了蜗牛老湿的<★tiny-rate 东半球最小的评级组件☆>,在大佬的启发下我就十分顺手的撸了一个移动端用的星级评价组件. 本篇会涉 ...

最新文章

  1. 《DSP using MATLAB》Problem 5.7
  2. hall's marriage theorem
  3. 【Kettle】第一篇,Pan 的使用
  4. kubernetes视频教程笔记 (39)-高可用的K8S构建-kubeadm部署安装
  5. linux安装打字软件
  6. 真正的高手,都在自讨苦吃——数显之家快讯之【SHIO世硕心语】
  7. python-给登记照换底色(蓝底变红底)
  8. 【运筹学】对偶理论 : 互补松弛性 ( 定理内容 | 定理证明 )
  9. WindowManager LayoutParams 上
  10. 软件开发管理规范(制度)
  11. 共享电单车属于哪个部门管理_对小区物业服务不满找谁投诉?哪个部门负责管理...
  12. java常见的5个异常_Java中常见的五种异常
  13. 智能投影机android系统,智能投影机
  14. redis取mysql数据类型_redis数据类型操作
  15. 基于Python的k均值聚类不同规格的商品名
  16. 【Android】动态获取当前背景图,根据背景图色动态改变字体颜色
  17. 全球与中国铟金属市场深度研究分析报告
  18. 配置Openfiler做ISCS实验
  19. 乌鸦救赎《恋商聊天课程》新1.0
  20. java testng 优化_Java自动化测试框架-10 - TestNG之测试结果篇(详细教程)

热门文章

  1. mysql行级安全_MySQL学习笔记(五):MySQL表级锁和行级锁
  2. pythonwin32api拖动图标_Python使用win32api,模拟鼠标移动并复制/粘贴到diskfi中
  3. c# wpf listbox 高度_WPF快速入门系列(1)——WPF布局概览
  4. php tsrmg,php garbage collect
  5. pandas pivot 计算占比_数据分析Pandas 基础(二)
  6. python手机端编程环境_移动端自动化测试解决方案(Appium + Python) - (1) 环境搭建...
  7. 2020南大计科考研实记(受难三跨)
  8. Sublime Text 2 使用心得
  9. c++与C# winform的消息通讯--(结构体与byte数组的使用)
  10. vs2012 boost配置