chart.showLoading({
color: "#0696e1", //加载动画颜色
maskColor: "rgb(18 30 78 / 80%)",
});
setTimeout(() => {
// setOption前隐藏loading事件
chart.hideLoading();
chart.setOption(option);
}, 1000);
setoption之后增加click点击事件
chart.on('click', function (params) {
console.log(params, 'params');
看后端要接收的参数是啥 我这是把城市名字传过去 盐城市 最后一个市都不要 截取一下
let cityName = params.name.slice(0, params.name.length - 1)
let url = '/bank/collectionData/collectiondep?cityName=' + cityName
window.location.href = url
});
created() {
// if (this.$route.query.indexName) {
// // 首页跳转的
// this.queryParams.eventType = this.$route.query.indexName
// }
console.log('decodeURIComponent(window.location.href)', decodeURIComponent(window.location.href).indexOf('?'));
判断路径是否有?这个是代码路径有传参数过来 要不然 不判断不跳转的时候 本身页面就获取是路径是当前的href就报错了
if (decodeURIComponent(window.location.href).indexOf('?') != -1) {
、、decodeURIComponent转码成中文
var href = decodeURIComponent(window.location.href);
var name = href.split('?')[1].split('=')[1];
console.log('naem', escape(name).indexOf("%u") < 0);
if (escape(name).indexOf("%u") < 0) {
这个是传参过来是数字的
this.queryParams.eventType = this.$route.query.indexName
} else {
这个是传参过来是中文的
this.queryParams.deptName = name
}
}
因为跳转到改页面比较多 然后根据window.locatio获取参数重新写一个
window.location.search; //获取url中"?"符后的字串
if (decodeURIComponent(window.location.href).indexOf('?') != -1) {
// 获取 URL 参数
const params = new URLSearchParams(window.location.search);
// 首页的地图城市名称
const cityNames = params.get('CityName');
// 首页的风险类型
const RiskId = params.get('RiskId');
// 系统画像的系统id
const systemId = params.get('SystemId');
if (cityNames) {
this.queryParams.deptName = cityNames
} if (RiskId) {
this.queryParams.eventType = RiskId
}
if (systemId) {
this.queryParams.systemId = systemId
}
}
详细可以查看这个博主的
https://blog.csdn.net/agua001/article/details/126340762?spm=1001.2101.3001.6650.4&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-4-126340762-blog-129139590.235%5Ev27%5Epc_relevant_multi_platform_whitelistv3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-4-126340762-blog-129139590.235%5Ev27%5Epc_relevant_multi_platform_whitelistv3&utm_relevant_index=5
图表点击跳转也可以使用router 之前没成功是因为指向问题
const that = this
const codeS = this.systemReview.systemCode
that.chart.on('click', function (params) {
// window.location.href = /bank/collectionData/collectiondep? SystemId=${codeS}&yesterDaty=${params.name}
that.$router.push({
path: '/bank/collectionData/collectiondep',
query: {
SystemId: codeS,
yesterDaty: params.name
},
});
});