在vue.js使用v-for遍历出的li中的@click事件在移动端无效,在网页端可以执行,代码如下

  1. <template>
  2. <div class="rating-section" ref="ratingSection">
  3. <div>
  4. <div class="comprehensive">
  5. <div class="score">
  6. <div class="mark">{{seller.score}}</div>
  7. <div class="text">综合评分</div>
  8. <div class="compare">高于周边商家{{seller.rankRate}}%</div>
  9. </div>
  10. <div class="service">
  11. <div class="service-item">
  12. <span class="lable-text">服务态度</span>
  13. <div class="star-container">
  14. <star :size="12" :score="seller.serviceScore"></star>
  15. </div>
  16. <span class="inline-score">{{seller.serviceScore}}</span>
  17. </div>
  18. <div class="service-item">
  19. <span class="lable-text">菜品评价</span>
  20. <div class="star-container">
  21. <star :size="12" :score="seller.foodScore"></star>
  22. </div>
  23. <span class="inline-score">{{seller.foodScore}}</span>
  24. </div>
  25. <div class="service-item">
  26. <span class="lable-text">送达时间</span>
  27. <span class="delivery">{{seller.deliveryTime}}分钟</span>
  28. </div>
  29. </div>
  30. </div>
  31. <div class="rating-container">
  32. <div class="setter">
  33. <rating-select :options="options"></rating-select>
  34. </div>
  35. <div class="rating-setting" @click="onlyContentClick">
  36. <span class="icon-check_circle" :class="{'highlight':onlyContent}"></span>
  37. <span class="text">只看有内容的评价</span>
  38. </div>
  39. <div class="rating-list">
  40. <ul>
  41. <li class="item-rating" v-for="item in ratings">
  42. <div class="avart">
  43. <img :src="item.avatar">
  44. </div>
  45. <div class="content">
  46. <div class="username">{{item.username}}</div>
  47. <div class="user-score">
  48. <div class="score">
  49. <star :size="12" :score="item.score"></star>
  50. </div>
  51. <span v-show="item.deliveryTime>0">{{item.deliveryTime}}分钟送达</span>
  52. </div>
  53. <div class="text">{{item.text}}</div>
  54. <div class="thumbs-up">
  55. <span class="split" :class="[{'icon-thumb_down':item.rateType===0},{'icon-thumb_up':item.rateType===1}]"></span>
  56. <span class="thumb-item split" v-for="r in item.recommend">{{r}}</span>
  57. </div>
  58. </div>
  59. </li>
  60. </ul>
  61. </div>
  62. </div>
  63. </div>
  64. </div>
  65. </template>
  66.  
  67. <script>
  68. import BScroll from 'better-scroll';
  69. import RatingSelect from '../ratingSelect/ratingSelect.vue';
  70. import star from '../star/star.vue';
  71. const ERROR_OK = 0;
  72. export default{
  73. data () {
  74. return {
  75. ratings: [],
  76. onlyContent: false,
  77. options: [
  78. {
  79. text: '全部',
  80. count: 57,
  81. type: 'positive'
  82. }, {
  83. text: '满意',
  84. count: 47,
  85. type: 'positive'
  86. }, {
  87. text: '不满意',
  88. count: 10,
  89. type: 'negative'
  90. }]
  91. };
  92. },
  93. created () {
  94. this.loadData();
  95. },
  96. props: {
  97. seller: {
  98. type: Object,
  99. default () {
  100. return {};
  101. }
  102. }
  103. },
  104. components: {star, RatingSelect},
  105. methods: {
  106. onlyContentClick () {
  107. this.onlyContent = !this.onlyContent;
  108. },
  109. loadData () {
  110. this.$http.get('/getRatings').then(res => {
  111. if (res.body.code === ERROR_OK) {
  112. this.ratings = res.body.result;
  113. this.$nextTick(() => {
  114. if (!this.ratingScroll) {
  115. this.initScroll();
  116. } else {
  117. this.ratingScroll.refresh();
  118. }
  119. });
  120. }
  121. });
  122. },
  123. initScroll () {
  124. this.ratingScroll = new BScroll(this.$refs.ratingSection, {
  125. click: true //better-scroll 默认会阻止浏览器的原生 click 事件。当设置为 true,better-scroll 会派发一个 click 事件
  126. });
  127. }
  128. }
  129. };
  130. </script>
  131.  
  132. <style scoped lang="stylus" rel="stylesheet/stylus">
  133. .rating-section
  134. position absolute;
  135. top 176px;
  136. bottom 0px;
  137. overflow hidden;
  138. width 100%;
  139. font-size 0;
  140. background-color rgb(243, 245, 247);
  141. .comprehensive
  142. display flex;
  143. padding 18px 0;
  144. background-color #FFF;
  145. border-bottom 1px solid rgba(7, 17, 27, .1);
  146. .score
  147. padding 0px 16px;
  148. border-right 1px solid rgba(7, 17, 27, .1);
  149. text-align center;
  150. .mark
  151. margin-bottom 6px;
  152. line-height 28px;
  153. font-size 24px;
  154. color rgb(255, 153, 0);
  155. .text
  156. margin-bottom 8px;
  157. line-height 12px;
  158. font-size 12px;
  159. color rgb(7, 17, 27);
  160. .compare
  161. margin-bottom 6px;
  162. line-height 10px;
  163. font-size 10px;
  164. color rgba(7, 17, 27, .6);
  165. .service
  166. flex 1;
  167. padding-left 16px;
  168. .service-item
  169. margin-bottom 8px;
  170. line-height 18px;
  171. font-size 12px;
  172. .lable-text
  173. color rgb(7, 17, 27);
  174. .inline-score
  175. color rgb(255, 153, 0);
  176. .delivery
  177. color rgb(147, 153, 159);
  178. .star-container
  179. display inline-block;
  180. &:last-child
  181. margin-bottom 0;
  182. .rating-container
  183. margin-top 18px;
  184. background-color #fff;
  185. border-top 1px solid rgba(7, 17, 27, .1);
  186. .setter
  187. padding 0 18px;
  188. border-bottom 1px solid rgba(7, 17, 27, .1);
  189. .rating-setting
  190. padding 12px 18px;
  191. font-size 0;
  192. color rgb(147, 153, 159);
  193. .icon-check_circle
  194. margin-right 4px;
  195. font-size 24px;
  196. &.highlight
  197. color #00c850;
  198. .text
  199. font-size 12px;
  200. line-height 24px;
  201. vertical-align top;
  202. .rating-list
  203. padding 18px 18px 0px 18px;
  204. border-top 1px solid rgba(7, 17, 27, .1);
  205. .item-rating
  206. display flex;
  207. padding 18px 0;
  208. font-size 12px;
  209. border-bottom 1px solid rgba(7, 17, 27, .1);
  210. &:first-child
  211. padding-top 0;
  212. .avart
  213. margin-right 12px;
  214. img
  215. width 28px;
  216. height 28px;
  217. border-radius 50%;
  218. .content
  219. font-size 10px;
  220. line-height 12px;
  221. .username
  222. color rgb(7, 17, 27);
  223. .user-score
  224. color rgb(147, 153, 159);
  225. .score
  226. display inline-block;
  227. .text
  228. margin-bottom 7px;
  229. font-size 12px;
  230. line-height 18px;
  231. color rgb(7, 17, 27);
  232. .thumbs-up
  233. .split
  234. margin-right 8px;
  235. &:last-child
  236. margin-right 0;
  237. .icon-thumb_up
  238. color #00a0dc;
  239. .icon-thumb_down
  240. color rgb(183, 187, 191);
  241. .thumb-item
  242. display inline-block;
  243. padding 0px 6px;
  244. margin-bottom 4px;
  245. line-height 16px;
  246. font-size 9px;
  247. color rgb(147, 153, 159);
  248. border-radius 2px;
  249. background-color rgb(255, 255, 240, .1);
  250. border 1px solid rgba(7, 17, 27, .1);
  251. </style>

应该是你使用了better-scroll的原因,默认它会阻止touch事件。所以在配置中需要加上click: true

具体的配置还可以查看https://github.com/ustbhuangyi/better-scroll

vue.js 1.0中用v-for遍历出的li中的@click事件在移动端无效的更多相关文章

  1. v-for遍历出的元素上添加click事件,获取对应元素上的属性id值

    <span v-for="(n,nav) in floorList" data-id="{{nav.itemId}}" v-on:click=" ...

  2. 还学的动吗? 盘点下Vue.js 3.0.0 那些让人激动的功能

    转载请注明出处:葡萄城官网,葡萄城为开发者提供专业的开发工具.解决方案和服务,赋能开发者. 原文出处:https://blog.bitsrc.io/vuejs-3-0-0-beta-features- ...

  3. 窥探Vue.js 2.0 - Virtual DOM到底是个什么鬼?

    引言 你可能听说在Vue.js 2.0已经发布,并且在其中新添加如了一些新功能.其中一个功能就是"Virtual DOM". Virtual DOM是什么 在之前,React和Em ...

  4. 窥探Vue.js 2.0

    title: 窥探Vue.js2.0 date: 2016-09-27 10:22:34 tags: vue category: 技术总结 --- 窥探Vue.js2.0 令人兴奋的Vue.js 2. ...

  5. Vue.js 2.0 参考手册.CHM下载

    下载地址 Vue.js 2.0 参考手册.CHM下载链接: http://pan.baidu.com/s/1kVbhd4b 密码: wxfh

  6. Vue.js 2.0版

    Vue.js 2.0版升级,更改了好多方法或指令 new Vue({ el:'#demo', data:{ msg:"vue2.0" } }) v-model lazy numbe ...

  7. Vue.js 2.0 和 React、Augular

    Vue.js 2.0 和 React.Augular 引言 这个页面无疑是最难编写的,但也是非常重要的.或许你遇到了一些问题并且先前用其他的框架解决了.来这里的目的是看看Vue是否有更好的解决方案.那 ...

  8. 基于Vue.js 2.0 + Vuex打造微信项目

    一.项目简介 基于Vue + Vuex + Vue-router + Webpack 2.0打造微信界面,实现了微信聊天.搜索.点赞.通讯录(快速导航).个人中心.模拟对话.朋友圈.设置等功能. 二. ...

  9. vue.js 2.0 官方文档学习笔记 —— 01. vue 介绍

    这是我的vue.js 2.0的学习笔记,采取了将官方文档中的代码集中到一个文件的形式.目的是保存下来,方便自己查阅. !官方文档:https://cn.vuejs.org/v2/guide/ 01. ...

随机推荐

  1. 解决putty自动断开的问题

    解决putty自动断开的问题 putty窗口上右键>change settings.打开后如下,修改seconds of keepalives,让putty每隔若干秒发送心跳包

  2. 深入理解Redis主键失效原理及实现机制(转)

    原文:深入理解Redis主键失效原理及实现机制 作为一种定期清理无效数据的重要机制,主键失效存在于大多数缓存系统中,Redis 也不例外.在 Redis 提供的诸多命令中,EXPIRE.EXPIREA ...

  3. Java线程安全和非线程安全

    ArrayList是非线程安全的,Vector是线程安全的:HashMap是非线程安全的,HashTable是线程安全的:StringBuilder是非线程安全的,StringBuffer是线程安全的 ...

  4. 007-组件和Props

    一.概述 组件让你可以将用户界面分成独立的,可重复使用的部分,并且可以独立思考每个部分. 从概念上讲,组件就像JavaScript函数一样.他们接受任意输入(称为“props”)并返回描述屏幕上应显示 ...

  5. Angular学习笔记—路由(转载)

    创建路由 1.首先安装 Angular Router.你可以通过运行以下任一操作来执行此操作: yarn add @angular/router # OR npm i --save @angular/ ...

  6. JS操作时间 - UNIX时间戳简单介绍

    准备知识 GMT(Greenwich Mean Time) - 格林尼治时间.UTC(Universal Time Code) - 国际协调时间.PST(Pacific Standard Time,太 ...

  7. 空基类优化empty base class optimization

    1.为什么C++中不允许类的大小是0 class ZeroSizeT {}; ZeroSizeT z[10]; &z[i] - &z[j]; 一般是用两个地址之间的字节数除以类型大小而 ...

  8. 微信小程序组件icon

    基础内容icon:官方文档 Demo Code Page({ data: { iconSize: [20, 30, 40, 50, 60, 70], iconColor: [ 'red', 'oran ...

  9. LeetCode:比较含退格字符串【844】

    LeetCode:比较含退格字符串[844] 题目描述 给定 S 和 T 两个字符串,当它们分别被输入到空白的文本编辑器后,判断二者是否相等,并返回结果. # 代表退格字符. 示例 1: 输入:S = ...

  10. cdoj1334郭大侠与Rabi-Ribi

    地址:http://acm.uestc.edu.cn/#/problem/show/1334 题目: 郭大侠与Rabi-Ribi Time Limit: 3000/1000MS (Java/Other ...