vue.js 1.0中用v-for遍历出的li中的@click事件在移动端无效
在vue.js使用v-for遍历出的li中的@click事件在移动端无效,在网页端可以执行,代码如下
- <template>
- <div class="rating-section" ref="ratingSection">
- <div>
- <div class="comprehensive">
- <div class="score">
- <div class="mark">{{seller.score}}</div>
- <div class="text">综合评分</div>
- <div class="compare">高于周边商家{{seller.rankRate}}%</div>
- </div>
- <div class="service">
- <div class="service-item">
- <span class="lable-text">服务态度</span>
- <div class="star-container">
- <star :size="12" :score="seller.serviceScore"></star>
- </div>
- <span class="inline-score">{{seller.serviceScore}}</span>
- </div>
- <div class="service-item">
- <span class="lable-text">菜品评价</span>
- <div class="star-container">
- <star :size="12" :score="seller.foodScore"></star>
- </div>
- <span class="inline-score">{{seller.foodScore}}</span>
- </div>
- <div class="service-item">
- <span class="lable-text">送达时间</span>
- <span class="delivery">{{seller.deliveryTime}}分钟</span>
- </div>
- </div>
- </div>
- <div class="rating-container">
- <div class="setter">
- <rating-select :options="options"></rating-select>
- </div>
- <div class="rating-setting" @click="onlyContentClick">
- <span class="icon-check_circle" :class="{'highlight':onlyContent}"></span>
- <span class="text">只看有内容的评价</span>
- </div>
- <div class="rating-list">
- <ul>
- <li class="item-rating" v-for="item in ratings">
- <div class="avart">
- <img :src="item.avatar">
- </div>
- <div class="content">
- <div class="username">{{item.username}}</div>
- <div class="user-score">
- <div class="score">
- <star :size="12" :score="item.score"></star>
- </div>
- <span v-show="item.deliveryTime>0">{{item.deliveryTime}}分钟送达</span>
- </div>
- <div class="text">{{item.text}}</div>
- <div class="thumbs-up">
- <span class="split" :class="[{'icon-thumb_down':item.rateType===0},{'icon-thumb_up':item.rateType===1}]"></span>
- <span class="thumb-item split" v-for="r in item.recommend">{{r}}</span>
- </div>
- </div>
- </li>
- </ul>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import BScroll from 'better-scroll';
- import RatingSelect from '../ratingSelect/ratingSelect.vue';
- import star from '../star/star.vue';
- const ERROR_OK = 0;
- export default{
- data () {
- return {
- ratings: [],
- onlyContent: false,
- options: [
- {
- text: '全部',
- count: 57,
- type: 'positive'
- }, {
- text: '满意',
- count: 47,
- type: 'positive'
- }, {
- text: '不满意',
- count: 10,
- type: 'negative'
- }]
- };
- },
- created () {
- this.loadData();
- },
- props: {
- seller: {
- type: Object,
- default () {
- return {};
- }
- }
- },
- components: {star, RatingSelect},
- methods: {
- onlyContentClick () {
- this.onlyContent = !this.onlyContent;
- },
- loadData () {
- this.$http.get('/getRatings').then(res => {
- if (res.body.code === ERROR_OK) {
- this.ratings = res.body.result;
- this.$nextTick(() => {
- if (!this.ratingScroll) {
- this.initScroll();
- } else {
- this.ratingScroll.refresh();
- }
- });
- }
- });
- },
- initScroll () {
- this.ratingScroll = new BScroll(this.$refs.ratingSection, {
- click: true //better-scroll 默认会阻止浏览器的原生 click 事件。当设置为 true,better-scroll 会派发一个 click 事件
- });
- }
- }
- };
- </script>
- <style scoped lang="stylus" rel="stylesheet/stylus">
- .rating-section
- position absolute;
- top 176px;
- bottom 0px;
- overflow hidden;
- width 100%;
- font-size 0;
- background-color rgb(243, 245, 247);
- .comprehensive
- display flex;
- padding 18px 0;
- background-color #FFF;
- border-bottom 1px solid rgba(7, 17, 27, .1);
- .score
- padding 0px 16px;
- border-right 1px solid rgba(7, 17, 27, .1);
- text-align center;
- .mark
- margin-bottom 6px;
- line-height 28px;
- font-size 24px;
- color rgb(255, 153, 0);
- .text
- margin-bottom 8px;
- line-height 12px;
- font-size 12px;
- color rgb(7, 17, 27);
- .compare
- margin-bottom 6px;
- line-height 10px;
- font-size 10px;
- color rgba(7, 17, 27, .6);
- .service
- flex 1;
- padding-left 16px;
- .service-item
- margin-bottom 8px;
- line-height 18px;
- font-size 12px;
- .lable-text
- color rgb(7, 17, 27);
- .inline-score
- color rgb(255, 153, 0);
- .delivery
- color rgb(147, 153, 159);
- .star-container
- display inline-block;
- &:last-child
- margin-bottom 0;
- .rating-container
- margin-top 18px;
- background-color #fff;
- border-top 1px solid rgba(7, 17, 27, .1);
- .setter
- padding 0 18px;
- border-bottom 1px solid rgba(7, 17, 27, .1);
- .rating-setting
- padding 12px 18px;
- font-size 0;
- color rgb(147, 153, 159);
- .icon-check_circle
- margin-right 4px;
- font-size 24px;
- &.highlight
- color #00c850;
- .text
- font-size 12px;
- line-height 24px;
- vertical-align top;
- .rating-list
- padding 18px 18px 0px 18px;
- border-top 1px solid rgba(7, 17, 27, .1);
- .item-rating
- display flex;
- padding 18px 0;
- font-size 12px;
- border-bottom 1px solid rgba(7, 17, 27, .1);
- &:first-child
- padding-top 0;
- .avart
- margin-right 12px;
- img
- width 28px;
- height 28px;
- border-radius 50%;
- .content
- font-size 10px;
- line-height 12px;
- .username
- color rgb(7, 17, 27);
- .user-score
- color rgb(147, 153, 159);
- .score
- display inline-block;
- .text
- margin-bottom 7px;
- font-size 12px;
- line-height 18px;
- color rgb(7, 17, 27);
- .thumbs-up
- .split
- margin-right 8px;
- &:last-child
- margin-right 0;
- .icon-thumb_up
- color #00a0dc;
- .icon-thumb_down
- color rgb(183, 187, 191);
- .thumb-item
- display inline-block;
- padding 0px 6px;
- margin-bottom 4px;
- line-height 16px;
- font-size 9px;
- color rgb(147, 153, 159);
- border-radius 2px;
- background-color rgb(255, 255, 240, .1);
- border 1px solid rgba(7, 17, 27, .1);
- </style>
应该是你使用了better-scroll的原因,默认它会阻止touch事件。所以在配置中需要加上click: true
具体的配置还可以查看https://github.com/ustbhuangyi/better-scroll
vue.js 1.0中用v-for遍历出的li中的@click事件在移动端无效的更多相关文章
- v-for遍历出的元素上添加click事件,获取对应元素上的属性id值
<span v-for="(n,nav) in floorList" data-id="{{nav.itemId}}" v-on:click=" ...
- 还学的动吗? 盘点下Vue.js 3.0.0 那些让人激动的功能
转载请注明出处:葡萄城官网,葡萄城为开发者提供专业的开发工具.解决方案和服务,赋能开发者. 原文出处:https://blog.bitsrc.io/vuejs-3-0-0-beta-features- ...
- 窥探Vue.js 2.0 - Virtual DOM到底是个什么鬼?
引言 你可能听说在Vue.js 2.0已经发布,并且在其中新添加如了一些新功能.其中一个功能就是"Virtual DOM". Virtual DOM是什么 在之前,React和Em ...
- 窥探Vue.js 2.0
title: 窥探Vue.js2.0 date: 2016-09-27 10:22:34 tags: vue category: 技术总结 --- 窥探Vue.js2.0 令人兴奋的Vue.js 2. ...
- Vue.js 2.0 参考手册.CHM下载
下载地址 Vue.js 2.0 参考手册.CHM下载链接: http://pan.baidu.com/s/1kVbhd4b 密码: wxfh
- Vue.js 2.0版
Vue.js 2.0版升级,更改了好多方法或指令 new Vue({ el:'#demo', data:{ msg:"vue2.0" } }) v-model lazy numbe ...
- Vue.js 2.0 和 React、Augular
Vue.js 2.0 和 React.Augular 引言 这个页面无疑是最难编写的,但也是非常重要的.或许你遇到了一些问题并且先前用其他的框架解决了.来这里的目的是看看Vue是否有更好的解决方案.那 ...
- 基于Vue.js 2.0 + Vuex打造微信项目
一.项目简介 基于Vue + Vuex + Vue-router + Webpack 2.0打造微信界面,实现了微信聊天.搜索.点赞.通讯录(快速导航).个人中心.模拟对话.朋友圈.设置等功能. 二. ...
- vue.js 2.0 官方文档学习笔记 —— 01. vue 介绍
这是我的vue.js 2.0的学习笔记,采取了将官方文档中的代码集中到一个文件的形式.目的是保存下来,方便自己查阅. !官方文档:https://cn.vuejs.org/v2/guide/ 01. ...
随机推荐
- 解决putty自动断开的问题
解决putty自动断开的问题 putty窗口上右键>change settings.打开后如下,修改seconds of keepalives,让putty每隔若干秒发送心跳包
- 深入理解Redis主键失效原理及实现机制(转)
原文:深入理解Redis主键失效原理及实现机制 作为一种定期清理无效数据的重要机制,主键失效存在于大多数缓存系统中,Redis 也不例外.在 Redis 提供的诸多命令中,EXPIRE.EXPIREA ...
- Java线程安全和非线程安全
ArrayList是非线程安全的,Vector是线程安全的:HashMap是非线程安全的,HashTable是线程安全的:StringBuilder是非线程安全的,StringBuffer是线程安全的 ...
- 007-组件和Props
一.概述 组件让你可以将用户界面分成独立的,可重复使用的部分,并且可以独立思考每个部分. 从概念上讲,组件就像JavaScript函数一样.他们接受任意输入(称为“props”)并返回描述屏幕上应显示 ...
- Angular学习笔记—路由(转载)
创建路由 1.首先安装 Angular Router.你可以通过运行以下任一操作来执行此操作: yarn add @angular/router # OR npm i --save @angular/ ...
- JS操作时间 - UNIX时间戳简单介绍
准备知识 GMT(Greenwich Mean Time) - 格林尼治时间.UTC(Universal Time Code) - 国际协调时间.PST(Pacific Standard Time,太 ...
- 空基类优化empty base class optimization
1.为什么C++中不允许类的大小是0 class ZeroSizeT {}; ZeroSizeT z[10]; &z[i] - &z[j]; 一般是用两个地址之间的字节数除以类型大小而 ...
- 微信小程序组件icon
基础内容icon:官方文档 Demo Code Page({ data: { iconSize: [20, 30, 40, 50, 60, 70], iconColor: [ 'red', 'oran ...
- LeetCode:比较含退格字符串【844】
LeetCode:比较含退格字符串[844] 题目描述 给定 S 和 T 两个字符串,当它们分别被输入到空白的文本编辑器后,判断二者是否相等,并返回结果. # 代表退格字符. 示例 1: 输入:S = ...
- cdoj1334郭大侠与Rabi-Ribi
地址:http://acm.uestc.edu.cn/#/problem/show/1334 题目: 郭大侠与Rabi-Ribi Time Limit: 3000/1000MS (Java/Other ...