前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >H5开发笔记

H5开发笔记

原创
作者头像
无忧366
修改2021-03-29 14:22:56
7960
修改2021-03-29 14:22:56
举报
文章被收录于专栏:Hello world

1.css实现自动隐藏scroll滚动条但不影响滚动功能

代码语言:javascript
复制
谷歌内核webkit
.container::-webkit-scrollbar {     display: none; //SafariandChrome }
IE或者Firefox
.container {     -ms-overflow-style: none; //IE 10+     overflow: -moz-scrollbars-none; //Firefox }

2.浮层去除底部滚动

代码语言:javascript
复制
  stopBodyScroll (isFixed) {
    let bodyEl = document.body
    let top = 0
    if (isFixed) {
      top = window.scrollY

      bodyEl.style.position = 'fixed'
      bodyEl.style.top = -top + 'px'
    } else {
      bodyEl.style.position = ''
      bodyEl.style.top = ''

      window.scrollTo(0, top) // 回到原先的top
    }
  }

参考地址:https://juejin.im/post/5a27cad56fb9a045186a9d94

3.sudo npm install   报错

代码语言:javascript
复制
gyp ERR!stackError: EACCES: permission denied, mkdir

sudo npm install -g appium --unsafe-perm=true --allow-root

4.vue watch中新旧值其中某个属性一样

代码语言:javascript
复制
 watch: {
   currentData: {
      handler(newValue, oldValue) {
         console.log(newValue.type,oldValue.type);
      }
   },
   deep: true
 },

解决方法:在computed中添加一个,在watch中监控这个

代码语言:javascript
复制
watch: {
   currentData: {
     handler(newValue, oldValue) {
        console.log(newValue.type,oldValue.type);
     }
   },
     deep: true
   },
   tmpType: {
     handler(newValue, oldValue) {
       if (newValue !== oldValue) {
       //在此执行变化后需要的操作
       }
    },
     deep: true
   }
},
computed: {
   tmpType: {
     get: function() {
       return this.data.data.type;
     }
   }
}

5.axios post x-www-form-urlencoded 请求方式

使用FormData传参数

代码语言:javascript
复制
 const fd = new FormData();
 fd.append("key", "value");
 axios.post("host", fd, { headers: { "Content-Type": "application/x-www-form-urlencoded" }, }).then((res: any) => {}

6.vue项目在safari中img图片不显示

img外层包一层,img设置100%

代码语言:javascript
复制
img {
 height: 100%;
 width: 100%;
}

7.文本溢出显示...+更多

代码语言:javascript
复制

<div class="ellipsis">
 <div class="ellipsis-container">
 <div class="ellipsis-content">content</div>
 <div class="ellipsis-ghost">
 <div class="ellipsis-placeholder"></div>
 <div class="ellipsis-more">...更多</div>
 </div>
 </div>
 </div>

.ellipsis {
 position: relative;
 background: rgb(230, 230, 230);
 width: 100%;
 max-height: 42px; /* h*n */
 line-height: 21px;
 overflow: hidden;
}
.ellipsis-container {
 position: relative;
 display: -webkit-box;
 -webkit-box-orient: vertical;
 -webkit-line-clamp: 2; /* n */
 font-size: 34px; /* 末位空白宽度 */
 color: transparent;
}
.ellipsis-content {
 color: #4a4a4a;
 display: inline;/* 注掉变成省略号 */
 vertical-align: top;
 font-size: 17px; /* f */
 line-height: 21px;
 font-weight: bolder;
}
.ellipsis-ghost {
 position: absolute;
 z-index: 1;
 top: 0;
 left: 50%;
 width: 100%;
 height: 100%;
 color: #000;
}
.ellipsis-ghost:before {
 content: "";
 display: block;
 float: right;
 width: 50%;
 height: 100%;
}
.ellipsis-placeholder {
 content: "";
 display: block;
 float: right;
 width: 50%;
 height: 38px; /* h*n */
}
.ellipsis-more {
 position: relative;
 float: right;
 font-size: 12px; /* f */
 width: 50px; /* w */
 height: 18px; /* h */
 margin-top: -18px; /* -h */
}

8.swiper的设置width后实际的宽度会比设置的小

解决:需要设置

代码语言:javascript
复制
slidesPerView: "auto",

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1.css实现自动隐藏scroll滚动条但不影响滚动功能
  • 2.浮层去除底部滚动
  • 3.sudo npm install   报错
  • 4.vue watch中新旧值其中某个属性一样
  • 5.axios post x-www-form-urlencoded 请求方式
  • 6.vue项目在safari中img图片不显示
  • 7.文本溢出显示...+更多
  • 8.swiper的设置width后实际的宽度会比设置的小
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档