随手记录前端开发中实用方法

  1. flex盒子中存在margin的子元素如何换行排列
    如图:子元素宽高不限

父级元素样式属性:
.tags { display: flex; flex-wrap: wrap; column-gap: 20px; row-gap: 20px; }
column-gap 每个子元素的横向间距
row-gap 每个子元素的纵向间距

  1. ios 系统中 app内嵌套的vebView video 自动全屏的解决方案

ios端设置allowsInlineMediaPlaybacktrue

web页面video标签设置 :webkit-playsinline="true" :playsinline="true" x-webkit-airplay="allow"

即可解决

  1. 微信小程序中的webview如何监页面被显示 类似于小程序onshow

vue页面创建时监听hashchange, 这里需要注意visibilitychange在小程序中并不生效. 此处小程序需要在onshow周期赋予webview的src一个时间戳参数

小程序

// 这段代码会在小程序每次onShow的时候被执行
// 请注意query.t每次都会变化 以便vue中hashchange监听到
 wx.getLocation({
      type: 'gcj02',
      altitude: true, //高精度定位
      success: res => {
        this.setData({
          haveLocation: true
        })
        this.data.latitude = res.latitude
        this.data.longitude = res.longitude
        console.log(res)
        this.setData({
          url: `${api.MALL_ROOT}list/home?c_access_key=${wx.getStorageSync('user').accessKey}&c_user_id=${wx.getStorageSync('user').userId}&c_latitude=${res.latitude}&c_longitude=${res.longitude}&wx=1&t=${(new Date()).valueOf()}`
        })
      },
      fail: err => {
        this.setData({
          haveLocation: false,
          url: `${api.MALL_ROOT}list/home?c_access_key=${wx.getStorageSync('user').accessKey}&c_user_id=${wx.getStorageSync('user').userId}&c_latitude=${this.data.latitude}&c_longitude=${this.data.longitude}&wx=1&t=${(new Date()).valueOf()}`
        })
      }
    })

vue

 window.addEventListener(
      'hashchange',
      function (e) {
        // console.log(that.GetRequest(e.oldURL), that.GetRequest(e.newURL))
        that.isLoaction(that.GetRequest(e.newURL))
        // 这里代码是做了一个用户是否开启定位的处理 可忽略
        if (!that.GetRequest(e.oldURL).c_latitude && that.GetRequest(e.newURL).c_latitude) {
          that.query.lat = that.GetRequest(e.newURL).c_latitude
          that.query.lon = that.GetRequest(e.newURL).c_longitude
          that.$refs.list.reLoad()
        }
      },
      false
    )

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

李二苟

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值