<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<style>
ul {
padding:
}
ul li {
list-style: none;
}
.tab ul{
position: relative;
background: #;
}
.tab ul li {
display: inline-block;
padding: 50px;
width: 100px;
height: 25px;
margin: ;
background: #ccc;
text-align: center;
border: 1px solid #;
}
.tab .bottom {
position: absolute;
left: ;
width: 100px;
height: 3px;
background: #f00;
transition: all .2s;
}
</style>
</head>
<body>
<div class="tab" id="box">
<ul ref ="tabWrapper">
<li v-for="(item, index) in list" @click="tabClick(index, $event)">{{item}}</li>
<div class="bottom" :style="style"></div>
</ul>
</div>
</body> <script>
new Vue({
el:'#box',
data:{
list: [,,,,],
style: {}
},
mounted() {
this.$nextTick(() => {
const firstLi = this.$refs.tabWrapper.querySelector('li:nth-of-type(1)')
this.style = {
left: firstLi.offsetLeft + 'px',
width: firstLi.offsetWidth +'px'
}
})
},
methods:{
tabClick(index, e) {
console.log(e)
console.log(e.target.offsetWidth)
console.log(e.target.offsetLeft)
this.style = {
left: e.target.offsetLeft + 'px',
width: e.target.offsetWidth +'px'
}
}
}
});
</script>
</html>

最新文章

  1. [Mahout] 完整部署过程
  2. CentOS 6.5下配置iSCSI网络存储
  3. iOS开发之网络数据解析(一)--JSON解析简介
  4. IT公司100题-16-层遍历二元树
  5. DIV CSS布局容易忽略的属性
  6. Android 异步加载神器Loader全解析
  7. 周末“干活”之 Mesos Meetup
  8. LinGo:疏散问题——线性规划,0-1规划
  9. 【微信公众号】验证用户OpenID是否关注某个公众号
  10. VMware workstation 10.0的永久key
  11. php生成html 伪静态??
  12. C#:求1到100的和
  13. 两个Map的对比,三种方法,将对比结果写入文件。
  14. android 开发 View _7_ 动态自定义View
  15. Mysql无法选取非聚合列
  16. python读、写、修改、追写excel文件
  17. 解决maven jmxtools 缺失的问题
  18. 【Ctsc2011】幸福路径
  19. spring cloud gateway之filter篇
  20. svn 使用笔记(一)

热门文章

  1. javascript正则表达式知识大全
  2. bzoj1688 疾病管理
  3. hdu1503 LCS
  4. Extended Traffic
  5. MySQL统计同比环比SQL
  6. @atcoder - AGC036D@ Negative Cycle
  7. 是时候了解React Native了
  8. BT17破解软件
  9. include 语句中使用双引号与括号有什么区别?
  10. 微信小程序 mode 的几种模式