Vue实现左侧可伸缩

摘要:
导出默认值{name:‘Home’,data(){return{openStatus:true,open_close:true,}},方法:{change()}this.openStatus=!this.openStatusif(this.open状态){setTimeout(()=˃{this.open_close=true},1000)}else{set超时(()=>{this.open_close=false},000)},},}.main{display:flex;width:100%;height:100vh;.left_main{margin:0;width:300px;text-align:center;background-color:aquamarine;transition:width1s;}。right-main{flex:1;背景颜色:棕色;位置:相对;.open_close{位置:绝对;左:0;顶部:0;颜色:白色;字体大小:24px;}}。left_main_show{width:0px;}}
<template>
 <div class="main">
  <div class="left_main" :class="{ left_main_show: !openStatus }"></div>
  <div class="right_main">
   <div class="open_close">
    <i @click="change" v-if="open_close" class="el-icon-s-fold"></i>
    <i @click="change" v-else class="el-icon-s-unfold"></i>
   </div>
  </div>
 </div>
</template>
<script>
export default {
 name: 'Home',
 data() {
  return {
   openStatus: true,
   open_close: true,
  }
 },
 methods: {
  change() {
   this.openStatus = !this.openStatus
   if (this.openStatus) {
    setTimeout(() => {
     this.open_close = true
    }, 1000)
   } else {
    setTimeout(() => {
     this.open_close = false
    }, 1000)
   }
  },
 },
}
</script>
<style lang="scss" scoped>
.main {
 display: flex;
 width: 100%;
 height: 100vh;
 .left_main {
  margin: 0;
  width: 300px;
  text-align: center;
  background-color: aquamarine;
  transition: width 1s;
 }
 .right_main {
  flex: 1;
  background-color: brown;
  position: relative;
  .open_close {
   position: absolute;
   left: 0;
   top: 0;
   color: white;
   font-size: 24px;
  }
 }
 .left_main_show {
  width: 0px;
 }
}
</style>

Vue实现左侧可伸缩第1张

免责声明:文章转载自《Vue实现左侧可伸缩》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇WinRAR 激活的小办法使用nebula把联想个人云存储映射到当前网络使用的方法下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

vue项目中使用动画钩子给项目添加复杂动画

常规的vue动画实现方式很简单,使用内置的transition组件就能轻易的实现,比如一个组件进场之后其子元素的动画可以这么写 <transition name="normal">      <div class="normal-player">        <div class="top">           ...

一个div有多个class,如何通过xpath获取?

 想要获取所有class=film-col的div 元素 @SuppressWarnings("unchecked")List<HtmlDivision> divs= (List<HtmlDivision>)page.getByXPath("//div[contains(@class, 'film-col')]");...

【Vue】09 Webpack Part5 Vue组件化开发

【Vue组件文件打包:Vue-Loader】 复制之前上一个项目 然后在我们的src目录中创建App.vue文件 这个文件就是Vue的模块文件 【建议下载IDEA的Vue.js插件】 Vue的模块分为template、script、style 其实就是代表html + javascript + css这三者 <template> <...

Vue项目中左右布局支持拉伸宽度

<template> <el-row :gutter="10"> <el-col :span="5" v-show="type === '2' && sidebar.opened" > <data-tree :t...

vue版本更新

之前电脑已经安装 Node环境和 vue-cli脚手架,但是过段时间没有使用,然后现在用 vue-cli 搭建项目的时候,启动服务器的时候报错,无法启动成功,摸索半天,发现是因为 Node和vue-cli 的版本过低,都需要更新,更新过后成功启动...... 以下是 Node 和 vue-cli 更新的总结: 一. vue-cli更新   在百度了好久,...

vue v-model 的注意点

在使用表单元素 input 的 v-model 指令时,碰到一个问题: 如上图,修改 input 的内容,以便随时显示;但显示时明显慢一步。 <template> <div> <input type="text" v-model="obj.val" @keyup="onUpdate"> <sp...