vue.js 使用记录(1)
2024-08-27 17:05:23
1,for循环
<li @click="toService(type, index)" v-for="(type,index) in typeList" :key="index" class="one_key_type_li">
{{type.serviceTypeName}}
</li>
2,route带参数
this.$router.push({
name: "ServiceSelect",
query: {
serviceTypeId: type.serviceTypeId,
serviceTypeName: type.serviceTypeName
}
}); //接收query参数
created() {
this.type = this.$route.query.serviceTypeId;
}
// 标签跳转
<router-link to="/Oncekey">
<span>跳转</span>
</router-link>
3,渲染后执行
this.$nextTick(() => {
setTimeout(function() {
document.getElementById("m" + id).focus();
}, 200);
});
4,store简单使用
// store.js
import Vue from "vue";
import Vuex from "vuex";
Vue.use(Vuex);
export default new Vuex.Store({
state: {
onceKeyId: ""
},
mutations: {
alterOnceKeyId(state, id) {
state.onceKeyId = id;
}
}
}); //获取id
this.$store.state.onceKeyId
//修改id
this.$store.commit('alterOnceKeyId', "2342");
5,transition动画
<transition name="slide-fade">
<ul v-if="typeList">
动画出现
</ul>
</transition> /* 可以设置不同的进入和离开动画 */
.slide-fade-enter-active {
transition: all .3s ease;
}
/*.slide-fade-leave-active {
transition: all .2s cubic-bezier(1.0, 0.5, 0.8, 1.0);
}*/
.slide-fade-enter, .slide-fade-leave-to
/* .slide-fade-leave-active for below version 2.1.8 */ {
transform: translateX(10px);
opacity: 0;
}
.fade-enter-active{
transition: opacity .6s;
}
.fade-enter{
opacity: .5;
}
最新文章
- 【ssh信任关系】解决信任关系不生效问题
- 深入理解CSS线性渐变linear-gradient
- 极光推送 JPush 项目简单使用
- angular的post请求,SpringMVC后台接收不到参数值的解决方案
- JS中的专业术语
- DEV:GridControl 筛选复选框 Checked Dropdown更改数据源
- 封装pdo单例模式类
- [jobdu]不用加减乘除做加法
- 详解Linux chgrp和chown命令的用法
- UVA - 11624 多点bfs [kuangbin带你飞]专题一
- linux 用户空间与内核空间——高端内存详解
- bzoj4361 isn(树状数组优化dp+容斥)
- Java Bug -- java.util.ConcurrentModificationException
- Oracle数据库入门——目录结构
- SQL 2016 AlwaysOn 无域AlwaysOn配置要点
- one-hot句子向量 对比度增强
- libopencv_shape.so.3.0: cannot open shared object file: No such file or directory 解决笔记
- YLZ开发后端外网编写
- linux键盘驱动
- 关于Google Android平台的ClockworkMod Recovery恢复模式