<template> <div class="app"> <keep-alive> <router-view></router-view> </keep-alive> </div> </template>
.....
created: function () {
console.log(1)
},
mounted: function () {
console.log(2)
},
activated: function () {
console.log(3)
},
deactivated: function () {
console.log(4)
}
.....
initData: function () {
let _this = this;
_this.fromLocation = JSON.parse(this.$route.query.fromLocation);
_this.toLocation = JSON.parse(this.$route.query.toLocation);
_this.activeIndex = parseInt(this.$route.params.activeIndex) || 0;
_this.policyType = parseInt(this.$route.params.policyType) || 0;
},
let swiperInstance = new Swiper('#swiper', {
pagination: '.swiper-pagination',
paginationClickable: false,
initialSlide: activeIndex,
onSlideChangeEnd: function (swiper) {
let _activeIndex = swiper.activeIndex;
_this.$route.params.activeIndex = _activeIndex;
// $router我放到了window上方便调用
window.$router.replace({
name: _this.$route.name,
params: _this.$route.params,
query: _this.$route.query
});
// 根据activeIndex,在这里初始化下面显示的数据
_this.transferDetail = _this.allData.plans[_activeIndex].segments;
_this.clearBusDetailFoldState();
}
});
export default {
name: 'transferMap',
data: function () {
return {
map: null,
}
},
methods: {
initData: function () {},
searchTransfer: function (type) {},
// 地图渲染 这个在transfer-map.html中使用
renderTransferMap: function (transferMap) {}
},
mounted: function () {
this.map = new AMap.Map("container", {
showBuildingBlock: true,
animateEnable: true,
resizeEnable: true,
zoom: 12 //地图显示的缩放级别
});
},
activated: function () {
let _this = this;
_this.initData();
// 设置title
setDocumentTitle('换乘地图');
_this.searchTransfer(_this.policyType).then(function (result) {
// 数据加载完成
// 换乘地图页面
let transferMap = result.plans[_this.activeIndex];
transferMap.origin = result.origin;
transferMap.destination = result.destination;
// 填数据
_this.transferMap = transferMap;
// 地图渲染
_this.renderTransferMap(transferMap);
});
},
deactivated: function () {
// 清理地图之前的标记
this.map.clearMap();
},
}
document.title = '页面名称';
function setDocumentTitle(title) {
"use strict";
//以下代码可以解决以上问题,不依赖jq
setTimeout(function () {
//利用iframe的onload事件刷新页面
document.title = title;
var iframe = document.createElement('iframe');
iframe.src = '/favicon.ico'; // 必须
iframe.style.visibility = 'hidden';
iframe.style.width = '1px';
iframe.style.height = '1px';
iframe.onload = function () {
setTimeout(function () {
document.body.removeChild(iframe);
}, 0);
};
document.body.appendChild(iframe);
}, 0);
}
function setDocumentTitle(title) {
//需要jQuery
var $body = $('body');
document.title = title;
// hack在微信等webview中无法修改document.title的情况
var $iframe = $('<iframe src="/favicon.ico"></iframe>');
$iframe.on('load', function () {
setTimeout(function () {
$iframe.off('load').remove();
}, 0);
}).appendTo($body);
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有