先佔坑,這兩天趁着不忙把博客更新下,真的很久沒更了,大概內容有如下幾部分(算是筆記吧)-2019-01-21javascript
字數過多省略號代替(需固定元素寬度)css
/* 單行省略 */ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; /* 兩行省略 */ text-overflow -o-ellipsis-lastline overflow hidden text-overflow ellipsis display -webkit-box -webkit-line-clamp 2 line-clamp 2 -webkit-box-orient vertical
inlineblock元素需設置統一的vertical-align 避免父元素高度不能正常顯示html
字符串判斷爲空或多個空前端
let commentTest = this.data.commentContent.split(' ').join('') // commentTest.length 爲0
手機號判斷vue
if (number.length == 0 || !(/^1[3456789]\d{9}$/.test(number)))
經過url跳轉傳參java
function getQueryVariable(variable){ var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i<vars.length;i++) { var pair = vars[i].split("="); if(pair[0] == variable){return pair[1];} } return(false); } var id= getQueryVariable("id");
元素內容複製到剪貼板web
<!-- jQuery --> $('.copy').click(function (e) { e.preventDefault(); const input = document.createElement('input'); document.body.appendChild(input); input.setAttribute('value', $('.dan').html()); input.select(); if (document.execCommand('copy')) { document.execCommand('copy'); console.log('複製成功'); showNotice('複製成功') } document.body.removeChild(input); });
jQuery頁面滾動ajax
$('.scroll_top').click(function(){$('html,body').animate({scrollTop: '0px'}, 800);}); // 滾動到頂部 $('.scroll_a').click(function(){$('html,body').animate({scrollTop:$('.a').offset().top}, 800);}); // 滾動到指定位置
用jQuery的prop()改變checkbox的checked不觸發change事件解決:在改變checked狀態後用change()$('.' + item + 'Input').prop('checked', true).change();
vue-router
vue-router中keep-alive的使用:小程序
<!-- 把須要緩存的組件name放入include便可 不會影響子路由動畫 --> <transition :name="transitionHome"> <keep-alive include="home,shop,rank,user"> <router-view></router-view> </keep-alive> </transition>
\r\n
在wx.showModal的content中換行 在開發者工具上顯示不換行,可是在真實環境下是正常換行的2019-02-12