2020-09-26-x
Xplorist Lv6

2020-09-26

todo-list

  • Vue分页组件中父组件与子组件通信交互
  • Vue表格组件添加表头表列固定功能

record-list

  • 子组件中点击事件后调用了父组件中的函数,父组件中改变了影响子组件的数据,但是子组件并没有重新初始化,
    问题出在哪儿?
  • 问题出在props的值传进去了,但是子组件的data属性中的值没有响应更新,那么需要响应式更新,就直接使用计算属性
  • 子组件调用父组件方法,除了通过props绑定事件,Vue特有的$emit(‘page-change’, inputPage)方式更为优雅

子组件

1
2
3
4

// PaginationContainer组件
<li v-if="curPage !== 1" v-on:click="pageClick(1), $emit('page-change', 1)">首页</li>

父组件html

1
2
<!-- 父组件调用PaginationContainer组件 -->
<pagination-container v-bind:msg="inputMsg" v-bind:option="pagiOption" v-on:page-change="listByPagi($event)"/>

父组件javascript

1
2
3
4
5
6
7
8
9
10
11
12
// 分页条件查询
listByPagi (pageIndex) {
this.pageIndex = pageIndex;
// 发送请求后,返回了数据
setTimeout(() => {
this.pageTotal = 500;
this.pageSize = 100;
this.rowTotal = 50000;

//this.rowList = [];
}, 1000);
},
  • Vue分页组件完成了
  • TableContainer组件中加入了表头表列固定的功能,Vue的数据驱动还是很厉害的,表头固定实现起来比DOM操作起来简单多了。

TableContainer组件html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<div class="table-container" v-on:scroll="scrollHandle($event)">
<table class="table table-bordered">
<tbody>
<tr v-for="(x, index) in rowList" v-bind:key="x.id">
<td class="tbody_left tbody_left_first_col" v-bind:style="{transform: 'translateX(' + scrollLeft + 'px)'}">
<button>查看</button>
<button>修改</button>
<button>删除</button>
<button>审核记录</button>
</td>
<td class="tbody_left" v-bind:style="{transform: 'translateX(' + scrollLeft + 'px)'}">{{ index + 1 }}</td>
<template v-for="(y, yIndex) in colList">
<td v-bind:key="yIndex">{{ x[y.id] }}</td>
</template>
</tr>
</tbody>
<thead v-bind:style="{transform: 'translateY(' + scrollTop + 'px)'}">
<tr>
<th class="thead_top_left thead_top_left_first_col" v-bind:style="{transform: 'translate(' + scrollLeft + 'px, 0px)'}">操作</th>
<th class="thead_top_left" v-bind:style="{transform: 'translate(' + scrollLeft + 'px, 0px)'}">序号</th>
<th class="thead_top" v-for="(x, index) in colList" v-bind:key="index">{{ x.name }}</th>
</tr>
</thead>
</table>
</div>

TableContainer组件JavaScript

1
2
3
4
5
6
methods: {
scrollHandle (event) {
this.scrollTop = event.target.scrollTop;
this.scrollLeft = event.target.scrollLeft;
},
},

Vue实现表头固定核心代码

1
2
3
4
5
6
7
8
9
10
11
12
// v-on:scroll就相当于监听了scroll时间
v-on:scroll="scrollHandle($event)"

// $event获取到scrollTop值和scrollLeft值,这样实现很优雅,没有任何DOM操作代码
scrollHandle (event) {
this.scrollTop = event.target.scrollTop;
this.scrollLeft = event.target.scrollLeft;
},

// 动态改变style的transform属性值,注意属性值需要为字符串格式(如:'translateX(' + scrollLeft + 'px)')
v-bind:style="{transform: 'translateX(' + scrollLeft + 'px)'}"

home-record-list

  • 星期六了,本应该去做平时计划周末做的事,软路由什么的,但是突然又没了动力,人就是这么无聊的动物。

  • 本周开始了前端的Vue组件使用之旅,让自己开始对组件这种东西非常感兴趣,自己写了两个Vue很实用的组件,感觉也蛮有成就感的。

  • 总结一下本周吧,这周平时貌似都在疯狂熬夜,折腾台式机,把整个电脑的硬盘都重新清了一遍,星期六了,自己也该搞点自己想做的事情了。

  • 本周六的目标就是软路由吧,毕竟还是要上谷歌云的,不用软路由的话有点说不过去,不过现在自己没有硬件,有的只是一个旧的笔记本,做个单臂路由试一下吧。

  • 自己想看电视了,玩客云还是该重新整起来,之前的那个美剧还么看完呢,讲硬件的感觉还听硬核的,硅谷主要讲的是偏软件。

  • 到了寝室就应该忘掉公司的事情,到了公司就应该忘记寝室做的东西,这样才能够愉快地玩耍。

  • 还可以折腾手机,刷机刷起来,刷miui12啊,还是先从软路由开始搞吧。

  • 参考了youtube上【不太老的老李】的视频,然后轻松折腾了一下,然后笔记本变成软路由了,然后装上了v2ray的插件,现在笔记本变成了真正的软路由了,还省去了买其他硬件路由器的麻烦,反正这台电脑也旧了。

  • 还是得感谢开源的大神们,youtube也是个好东西,能够学到很多实用的技术,现在手机上秒开YouTube的4k高清视频。

  • 安才君的路由器太垃圾了,还是我买的400块的蒲公英路X5路由器好,之前试过了旧版本的固件,估计是静态ip设置错了,还是该早点试一下最新版本的固件,一直以为是自己的笔记本硬件不支持,看来没有那么高深。

  • 软路由的事情就这样告以段落,接下来该折腾玩客云了,玩客云的速度应该比其他的下载工具是要快一些,还可以当作一个NAS,重新开始使用PotPlayer了,真的是神器,在线播放局域网中的文件,设置播放速度,那么现在
    玩客云的事情也搞完了。

  • 明天开始刷机,刷miui12。

  • 搜素 Halt and Catch Fire 迅雷下载 下载电脑狂人/奔腾年代 美剧,关于硬件开发的美剧,挺喜欢的。

  • 还没睡觉,然后下了个OnePlus通用刷机工具,然后刷了个小米6的高通骁龙835的包,然后开机重启就ok了,刷机也搞完了。目标全部完成,该睡觉了。

reference-site-list

soft router

 评论
// variables $gt-color-main := #6190e8 $gt-color-sub := #a1a1a1 $gt-color-loader := #999999 $gt-color-error := #ff3860 $gt-color-hr := #e9e9e9 $gt-color-comment-txt := #333333 $gt-color-link-active := #333333 $gt-color-btn := #ffffff $gt-size-base := 16px // default font-size $gt-size-border-radius := 5px $gt-breakpoint-mobile := 479px $gt-mask-z-index := 9999 // functions & mixins clearfix() { &:before &:after { display table clear both content "" } } em($px, $base-size = $gt-size-base) { u = unit($px) if (u is 'px') { unit($px / $base-size, 'em') } else { unit($px, u) } } mobile() { @media (max-width $gt-breakpoint-mobile) { {block} } } // variables - calculated $gt-size-loader-dot := em(6px) $gt-size-loader := em(28px) $gt-size-avatar := em(50px) $gt-size-avatar-mobi := em(32px) // styles // Put everything under container to avoid style conflicts .comments-container { .gt-container { box-sizing border-box * { box-sizing border-box } font-size $gt-size-base // common a { color $gt-color-main &:hover { color lighten($gt-color-main, 20%) border-color lighten($gt-color-main, 20%) } &.is--active { color $gt-color-link-active cursor default !important &:hover { color $gt-color-link-active } } } .hide { display none !important } // icons .gt-svg { display inline-block width em(16px) height em(16px) vertical-align sub svg { width 100% height 100% fill $gt-color-main } } .gt-ico { display inline-block &-text { margin-left em(5px) } &-github { width 100% height 100% .gt-svg { width 100% height 100% } svg { fill inherit } } } // loader .gt-spinner { position relative &::before { position absolute top 3px box-sizing border-box width em(12px) height em(12px) margin-top em(-3px) margin-left em(-6px) border 1px solid $gt-color-btn border-top-color $gt-color-main border-radius 50% animation gt-kf-rotate 0.6s linear infinite content '' } } .gt-loader { position relative display inline-block width $gt-size-loader height $gt-size-loader font-style normal // font-size: $gt-size-loader line-height $gt-size-loader border 1px solid $gt-color-loader border-radius 50% animation ease gt-kf-rotate 1.5s infinite &:before { position absolute top 0 left 50% display block width $gt-size-loader-dot height $gt-size-loader-dot margin-top -($gt-size-loader-dot / 2) margin-left -($gt-size-loader-dot / 2) background-color $gt-color-loader border-radius 50% content '' } } // avatar .gt-avatar { display inline-block width $gt-size-avatar height $gt-size-avatar +mobile() { width $gt-size-avatar-mobi height $gt-size-avatar-mobi } img { width 100% height auto border-radius 3px } &-github { width $gt-size-avatar - em(2px) height $gt-size-avatar - em(2px) cursor pointer +mobile() { width $gt-size-avatar-mobi - em(2px) height $gt-size-avatar-mobi - em(2px) } } } // button .gt-btn { display inline-block padding em(12px) em(20px) color $gt-color-btn font-size em(12px) line-height 1 white-space nowrap text-decoration none background-color $gt-color-main border 1px solid $gt-color-main border-radius $gt-size-border-radius outline none cursor pointer &-text { font-weight 400 } &-loading { position relative display inline-block width em(12px) height em(16px) margin-left em(8px) vertical-align top } &.is--disable { cursor not-allowed opacity 0.5 } &-login { margin-right 0 } &-preview { color $gt-color-main background-color var(--background-color) &:hover { background-color var(--second-background-color) } } &-public { &:hover { background-color lighten($gt-color-main, 20%) border-color lighten($gt-color-main, 20%) } } } } &-loadmore // loadmore /* error */ .gt-error { margin em(10px) color $gt-color-error text-align center } // initing .gt-initing { padding em(20px) 0 text-align center &-text { margin em(10px) auto font-size 92% } } // no int .gt-no-init { padding em(20px) 0 text-align center } // link .gt-link { border-bottom 1px dotted $gt-color-main &-counts &-project { text-decoration none } } // meta .gt-meta { position relative z-index 10 margin em(20px) 0 padding em(16px) 0 font-size em(16px) border-bottom 1px solid $gt-color-hr clearfix() } .gt-counts { margin 0 em(10px) 0 0 color var(--default-text-color) } .gt-user { float right margin 0 font-size 92% &-pic { width 16px height 16px margin-right em(8px) vertical-align top } &-inner { display inline-block cursor pointer .gt-user-name { color var(--default-text-color) } } .gt-ico { margin 0 0 0 em(5px) svg { fill var(--default-text-color) } } .is--poping { .gt-ico { svg { fill $gt-color-main } } } } .gt-version { margin-left em(6px) color $gt-color-sub } .gt-copyright { margin 0 em(15px) em(8px) padding-top em(8px) border-top 1px solid var(--border-color) } // popup .gt-popup { position absolute top em(38px) right 0 display inline-block padding em(10px) 0 font-size em(14px) letter-spacing 0.5px background var(--background-color) border 1px solid var(--border-color) .gt-action { position relative display block margin em(8px) 0 padding 0 em(18px) text-decoration none cursor pointer &.is--active { &:before { position absolute top em(7px) left em(8px) width em(4px) height em(4px) background $gt-color-main content '' } } } } // header .gt-header { position relative display flex &-comment { flex 1 margin-left em(20px) +mobile() { margin-left em(14px) } } &-textarea { display block box-sizing border-box width 100% min-height em(82px) max-height em(240px) padding em(12px) color var(--default-text-color) font-size em(14px) word-wrap break-word background-color var(--fourth-text-color) border 1px solid var(--border-color) border-radius $gt-size-border-radius outline none transition all 0.25s ease resize vertical &:hover { background-color var(--background-color) } } &-preview { padding em(12px) background-color var(--background-color) border 1px solid var(--border-color) border-radius $gt-size-border-radius } &-controls { position relative margin em(12px) 0 0 clearfix() +mobile() { margin 0 } &-tip { color $gt-color-main font-size em(14px) text-decoration none vertical-align sub +mobile() { display none } } .gt-btn { float right margin-left em(20px) +mobile() { float none width 100% margin em(12px) 0 0 } } } } &:after { position fixed top 0 right 0 bottom 100% left 0 opacity 0 content '' } &.gt-input-focused { position relative &:after { position fixed top 0 right 0 bottom 0 left 0 z-index $gt-mask-z-index background #000 opacity 0.6 transition opacity 0.3s, bottom 0s content '' } .gt-header-comment { z-index $gt-mask-z-index + 1 } } // comments .gt-comments { padding-top em(20px) &-null { text-align center } &-controls { margin em(20px) 0 text-align center } } // comment .gt-comment { position relative display flex padding em(10px) 0 &-content { flex 1 margin-left em(20px) padding em(12px) em(16px) overflow auto background-color var(--second-background-color) transition all ease 0.25s +mobile() { margin-left em(14px) padding em(10px) em(12px) } } &-header { position relative margin-bottom em(8px) font-size em(14px) } &-block-1 { float right width em(32px) height em(22px) } &-block-2 { float right width em(64px) height em(22px) } &-username { color $gt-color-main font-weight 500 text-decoration none &:hover { text-decoration underline } } &-text { margin-left em(8px) color $gt-color-sub } &-date { margin-left em(8px) color $gt-color-sub } &-like &-edit &-reply { position absolute height em(22px) &:hover { cursor pointer } } &-like { top 0 right em(32px) } &-edit &-reply { top 0 right 0 } &-body { // color: $gt-color-comment-txt !important color var(--second-text-color) !important .email-hidden-toggle a { display inline-block height 12px padding 0 9px color #444d56 font-weight 600 font-size 12px line-height 6px text-decoration none vertical-align middle background #dfe2e5 border-radius 1px &:hover { background-color #c6cbd1 } } .email-hidden-reply { display none white-space pre-wrap .email-signature-reply { margin 15px 0 padding 0 15px color #586069 border-left 4px solid #dfe2e5 } } .email-hidden-reply.expanded { display block } } &-admin { .gt-comment-content { background-color var(--fourth-text-color) } } } @keyframes gt-kf-rotate { 0% { transform rotate(0) } 100% { transform rotate(360deg) } } }