温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

使用vue怎么实现一个圆形菜单栏组件

发布时间:2021-03-29 18:04:52 阅读:730 作者:Leah 栏目:web开发
Vue开发者专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

本篇文章给大家分享的是有关使用vue怎么实现一个圆形菜单栏组件,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。

<template>
 <div id="cn-wrapper" : class="cn-wrapper" >
  <ul>
   <li @click="clickPanel(item)" v-for="(item,index) in panel" :key="index">
    <a href="#">
     <img class="li-img" :src="item.img" alt />
     <div class="li-text">{{item.title}}</div>
    </a>
   </li>
  </ul>
 </div>
</template>
 
<script >
// import { Component, Prop, Vue,Emit } from 'vue-property-decorator';
 
// @Component
// export default class CirclePanel extends Vue {
//  private rotatePanel=0;
//  @Prop() panel!: any;
 
//  mounted(){
//   this.initPanel()
//  }
 
//   // 操作版
//  @Emit()
//  clickPanel(item:any){
//   return item;
//  }
//  initPanel(){
//   let panel=document.getElementById("cn-wrapper") as HTMLElement;
//   let panelMan = new Hammer.Manager(panel);
//   panelMan.add(new Hammer.Pan({
//     threshold: 0
//    }));
//   panelMan.on('panstart', (ev: any) => {
//    if (ev.center.x < panel.clientWidth/2) {//左边
//     this.rotatePanel= this.rotatePanel - ev.angle
//    }else{
//     this.rotatePanel= this.rotatePanel + ev.angle
//     }
//   });
//  }
// }
 
export default {
   data () {
      return {
         rotatePanel0
      }
   },
   props: {
      panel: {
         typeArray,
         default: [    {img:'pics-gem/1.png',title:'一月石榴石'},
    {img:'pics-gem/2.png',title:'一月石榴石'},
    {img:'pics-gem/3.png',title:'一月石榴石'},
    {img:'pics-gem/4.png',title:'一月石榴石'},
    {img:'pics-gem/5.png',title:'一月石榴石'},
    {img:'pics-gem/6.png',title:'一月石榴石'},
    {img:'pics-gem/7.png',title:'一月石榴石'},
    {img:'pics-gem/8.png',title:'一月石榴石'},
    {img:'pics-gem/9.png',title:'一月石榴石'},
    {img:'pics-gem/10.png',title:'一月石榴石'},
    {img:'pics-gem/11.png',title:'一月石榴石'},
    {img:'pics-gem/12.png',title:'一月石榴石'},]
      },
   },
   activated(){
    this.initPanel()
   },
   methods: {
     // 操作版
     clickPanel(item){
      this.$emit('clickPanel',{item})
     },
     initPanel(){
      let panel=document.getElementById("cn-wrapper");
      let panelMan = new Hammer.Manager(panel);
      panelMan.add(new Hammer.Pan({
        threshold0
       }));
      panelMan.on('panstart'(ev) => {
       if (ev.center.x < panel.clientWidth/2) {//左边
        this.rotatePanelthis.rotatePanel - ev.angle
       }else{
        this.rotatePanelthis.rotatePanel + ev.angle
        }
      });
     }
   }
}
</script>
 
<style scoped>
.cn-wrapper {
 font-size1em;
 width24em;
 height24em;
 overflow: hidden;
 position: fixed;
 z-index10;
 bottom84px;
 margin-left: -288px;
 left50%;
 border-radius50%;
 -webkit-transformscale(0.1);
 -ms-transformscale(0.1);
 -moz-transformscale(0.1);
 transformscale(1);
 /* pointer-events: none; */
 -webkit-transition: all 0.3s ease;
 -moz-transition: all 0.3s ease;
 transition: all 0.3s ease;
}
 
.cn-wrapper li {
 position: absolute;
 font-size1.5em;
 width10em;
 height10em;
 -webkit-transform-origin100% 100%;
 -moz-transform-origin100% 100%;
 -ms-transform-origin100% 100%;
 transform-origin100% 100%;
 overflow: hidden;
 left50%;
 /* top: 50%; */
 margin-top: -2em;
 /* border: solid 1px #f2cc81; */
 margin-left: -10em;
 -webkit-transition: border 0.3s ease;
 -moz-transition: border 0.3s ease;
 transition: border 0.3s ease;
}
 
.cn-wrapper li a {
 display: block;
 font-size1.18em;
 height14.5em;
 width14.5em;
 /* position: absolute; */
 position: fixed; /* fix the "displacement" bug in webkit browsers when using tab key */
 bottom: -7.25em;
 right: -7.25em;
 border-radius50%;
 text-decoration: none;
 color#fff;
 padding-top1em;
 text-align: center;
 -webkit-transformskew(-60degrotate(-70degscale(1);
 -ms-transformskew(-60degrotate(-70degscale(1);
 -moz-transformskew(-60degrotate(-70degscale(1);
 transformskew(-60degrotate(-70degscale(1);
 -webkit-backface-visibility: hidden;
 -webkit-transition: opacity 0.3s, color 0.3s;
 -moz-transition: opacity 0.3s, color 0.3s;
 transition: opacity 0.3s, color 0.3s;
}
 
/* for a central angle x, the list items must be skewed by 90-x degrees
in our case x=40deg so skew angle is 50deg
items should be rotated by x, minus (sum of angles - 180)2s (for this demo) */
 
.cn-wrapper li:first-child {
 transformrotate(-10degskew(60deg);
}
 
.cn-wrapper li:nth-child(2) {
 transformrotate(20degskew(60deg);
}
 
.cn-wrapper li:nth-child(3) {
 transformrotate(50degskew(60deg);
}
 
.cn-wrapper li:nth-child(4) {
 transformrotate(80degskew(60deg);
}
 
.cn-wrapper li:nth-child(5) {
 transformrotate(110degskew(60deg);
}
.cn-wrapper li:nth-child(6) {
 transformrotate(140degskew(60deg);
}
.cn-wrapper li:nth-child(7) {
 transformrotate(170degskew(60deg);
}
.cn-wrapper li:nth-child(8) {
 transformrotate(200degskew(60deg);
}
.cn-wrapper li:nth-child(9) {
 transformrotate(230degskew(60deg);
}
.cn-wrapper li:nth-child(10) {
 transformrotate(260degskew(60deg);
}
.cn-wrapper li:nth-child(11) {
 transformrotate(290degskew(60deg);
}
.cn-wrapper li:nth-child(12) {
 transformrotate(320degskew(60deg);
}
 
.cn-wrapper li:nth-child(odd) a {
 background-color#a11313;
 background-colorhsla(088%63%1);
}
 
.cn-wrapper li:nth-child(even) a {
 background-color#a61414;
 background-colorhsla(088%65%1);
}
 
/* active style */
.cn-wrapper li.active a {
 /* background-color: #b31515;
 background-color: hsla(0, 88%, 70%, 1); */
 background-colorrgba(1351371550.52);
 border: solid 0px #f2cc81;
}
 
/* hover style */
.cn-wrapper li:not(.activea:hover,
.cn-wrapper li:not(.activea:active,
.cn-wrapper li:not(.activea:focus {
 background-colorrgba(1351371550.52);
 border: solid 0px #f2cc81;
}
 
.li-img {
 width50px;
 margin-bottom44px;
 margin-left: -30px;
}
.li-text {
 color#f2cc81;
 font-size20px;
 line-height1.4;
 width76px;
 margin0 calc(50% - 50px);
}
</style>

父组件调用:

 <div class="making-panel">
     <CirclePanel :title="title" :panel="panel"
           @clickTab="clickTabCircle"
           @clickPanel="clickPanel" ></CirclePanel>
  </div>

以上就是使用vue怎么实现一个圆形菜单栏组件,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注亿速云行业资讯频道。

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

vue
AI

开发者交流群×