首先 install vuex

创建store文件夹

在 store 文件夹分别建立

state.js

// 状态管理
// 定义state 原始数据
const state = {
fullScreen: false
} export default state

mutation-types.js

// 定义Mutations相关的字符串常量
// Mutations的修改动作
export const SET_FULL_SCREEN = 'SET_FULL_SCREEN'

mutations.js

// Mutations 定义对数据修改的逻辑
import * as types from './mutation-types' const mutations = {
[types.SET_FULL_SCREEN](state, flag) {
state.fullScreen = flag
}
} export default mutations

actions.js

// 对mutation进行封装
import * as types from './mutation-types' export const selectPlay = function ({commit, state}, {list, index}) {
commit(types.SET_FULL_SCREEN, true)
}

getters.js

// 获取state 对数据进行映射 用getters取state的数据去到组件里
// getters可以是个函数 类似于计算属性 可以根据state的不同值计算出新的值 可以在getters里写一些复杂的判断逻辑 export const fullScreen = state => state.fullScreen

index.js

// 入口
import Vue from 'vue'
import Vuex from 'vuex'
import * as actions from './actions'
import * as getters from './getters'
import state from './state'
import mutations from './mutations'
import createLogger from 'vuex/dist/logger' Vue.use(Vuex) const debug = process.env.NODE_ENV !== 'production' export default new Vuex.Store({
actions,
getters,
state,
mutations,
strict: debug,
plugins: debug? [createLogger()] : []
})

在main.js导入store

import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store' /* eslint-disable no-new */
new Vue({
el: '#app',
store,
router,
render: h => h(App)
})

创建meow.vue

<template>
<div class="meow">
<transition name="normal">
<div class="normal-vue" v-show="fullScreen">
<div class="background">
</div>
<div class="top">
<div class="back" @click="back">
<i class="icon-back"></i>
</div>
<h1 class="title"></h1>
<h2 class="subtitle"></h2>
</div>
</div>
</transition>
<transition name="mini">
<div class="mini-vue" v-show="fullScreen">
<div class="icon">
</div>
<div class="text">
<h2 class="name"></h2>
<p class="desc"></p>
</div>
</div>
</transition>
</div>
</template>

script

<script type="text/ecmascript-6">
import { mapGetters, mapMutations } from 'vuex' export default {
computed: {
...mapGetters([
'fullScreen'
])
},
methods: {
back() {
this.setFullScreen(false)
},
open() {
this.setFullScreen(true)
},
...mapMutations({
setFullScreen: 'SET_FULL_SCREEN'
})
} }
</script>

css

<style lang="stylus" scoped>
.meow
.normal-vue
position: fixed
left:
right:
top:
bottom:
z-index:
background: #aaaaaa
.background
position: absolute
left:
top:
width: %
height: %
z-index: -
opacity: 0.6
filter: blur(20px)
.top
position: relative
margin-bottom: 25px
.back
position absolute
top:
left: 6px
z-index:
.icon-back
display: block
padding: 9px
font-size: 16px
color: #003a39
transform: rotate(-90deg)
.title
width: %
margin: auto
line-height: 40px
text-align: center
no-wrap()
font-size: 18px
color: #fff
.subtitle
line-height: 20px
text-align: center
font-size: 14px
color: #fff
.mini-vue
display: flex
align-items: center
position: fixed
left:
bottom:
z-index:
width: %
height: 60px
background: #a1a1a1
.icon
flex: 40px
width: 40px
padding: 10px 20px
.text
display: flex
flex-direction: column
justify-content: center
flex:
line-height: 20px
overflow: hidden
.name
margin-bottom: 2px
no-wrap()
font-size: 14px
color: #fff
.desc
no-wrap()
font-size: 12px
color: #
</style>

vue--动画收缩的更多相关文章

  1. vue动画的用法

    vue动画 在vue.js中有两种写动画的方法,第一种就是像js里一样,用原生代码来实现,第二种则是使用animate.css的动画类文件,这个动画类和bootstrap.css文件类似,直接调用类就 ...

  2. vue动画及其原理

    1,vue动画的实现原理,主要是通过在不同时期给需要动画的dom元素加上css动画样式 我们以显示和隐藏动画为例 a, 需要动画的dom元素 b,点击时vue控制往vue中加的样式 2,  我们以两张 ...

  3. vue教程3-02 vue动画

    vue教程3-02 vue动画 以下代码,已经用包管理器下载好vue,animate <!DOCTYPE html> <html lang="en"> &l ...

  4. vue动画实现方式

    vue动画实现方式 <!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset=&q ...

  5. vue动画理解,进入、离开、列表过度和路由切换。

    vue的动画对于很多初学者,甚至对很多老鸟来说也是很费劲,不容易控制的. 这篇文章讲vue动画的理解.其实没那么难. 动画理解 一个元素从A状态变成B状态,如果这个过程通过某种方式反应在视图上了,那么 ...

  6. Vue动画操作

    概述 Vue 在插入.更新或者移除 DOM 时,提供多种不同方式的应用过渡效果.包括以下工具: 在 CSS 过渡和动画中自动应用 class 可以配合使用第三方 CSS 动画库,如 Animate.c ...

  7. vue 动画原理 part1

    Vue动画原理 增加和删除css增加样式实现一个过渡效果也就是动画效果 1.需要动画效果的标签外包裹一个transition标签 会被自动分析css样式,然后自动构建一个动画流程 transition ...

  8. Javascript - Vue - 动画

    动画状态类名 vue动画通过将需要执行动画的标签放入transition标签中,再通过设置预置的vue动画类名的css样式来控制动画的呈现效果. 开场动画状态的三个类名 v-enter:动画开始之前的 ...

  9. 15.vue动画& vuex

    Vue.config.productionTip = false; ==是否显示提示信息== ==import/export== export xxx 必须跟跟对象或者和定义一起 对象: export ...

  10. vue动画

    最近想搞搞vue的过渡和动画,以为照着官网写就好了,谁知道还是出现一些状况 具体表现就是不用webpack打包时候写的过渡是正常的,而用了webpack打包就不正常了 说使用了未定义的element: ...

随机推荐

  1. Java开发规范总结

     Service / DAO 层方法命名规约: 1 ) 获取单个对象的方法用 get 做前缀.2 ) 获取多个对象的方法用 list 做前缀.3 ) 获取统计值的方法用 count 做前缀.4 ) 插 ...

  2. 关于$ORACLE_HOME/bin/oracle文件属性

    OS:AIX 7.1DB:12.1.0.2.0 RAC oracle@DB01:/home/oracle>sqlplus / as sysdba SQL*Plus: Release 12.1.0 ...

  3. Oauth2.0安全问题浅谈

    大家如果对Oauth还不是很了解可以先看下这篇文章https://www.cnblogs.com/maoxiaolv/p/5838680.html 我这篇博客主要是总结一下安全测试过程中遇到Oauth ...

  4. 计算机网络网络层的IP地址划分及子码

    现在在网络层,即就是TCP/IP协议里的网际互联层,最流行IP协议的就是IPV4.其中IP地址的格式是由32位二进制数字表示的,通常为了人们阅读习惯,将其转换成点分十进制来表示,如:192.168.1 ...

  5. Ajax请求二进制流并在页面展示

    后端代码: public void getIntegralQrcode(HttpServletResponse response, String token) throws BizException, ...

  6. openwrt路由器进入安全模式

    openwrt路由器型号:WNDR3800 一.实验背景 在pc机上通过xshell软件登录openwrt路由器,pc机通过网线与openwrt路由器的LAN接口相连.openwrt路由器自带两块无线 ...

  7. IDEA建立Spring MVC Hello World 详细入门教程

    https://www.cnblogs.com/wormday/p/8435617.html

  8. Spring:容器基本用法

    bean是Spring 最核心的东西,打个比方,假设Spring是一个水桶,那么bean就是水桶里的水,水桶离开水后,就没啥作用了.我们先来看一下bean的定义: public class Perso ...

  9. java基础——IO流之File类

    1.File类的构造方法: File(String  pathName):通过一个指定的字符串类型路径来创建一个文件对象 File  (String parent,String child):通过指定 ...

  10. JavaBean初识

    JavaBean是一种特殊的java类,是一个通过Java代码实现的可重用组件. 简单来理解就是,将一些重用性较高的代码进行组合封装,以降低代码的重复性,使得开发更加简洁高效,也便于管理和修改. Ja ...