Element-ui+Vue 的el-menu菜单第二次点击刷新解决方案

在html页面 加上属性@select="handleSelect",如以下代码: 

                 
                    
                        
                        
                            小程序使用监控
                        
                      
                    
                    
                

 

1、修改router数组对象的item里面的component:{ template:'' },component.template 内容修改添加一个iframe 的ID,对应routers 里item的name,如name:listener,则iframe的ID为:iframe_listener;

2、在JS 添加vue的method 方法 handleSelect,如下:

Vue.prototype.axios = axios;
Vue.use(VueRouter);
const router = new VueRouter({
    routes: [        
        {
            path: '/listener',
            name: 'listener',
            component: {
                template: `
                   
` } } ] }) new Vue({ el: "#app", router: router, created() { this.url = 'xxxx'; }, mounted() {}, filters: {}, methods: { handleSelect(key, keyPath){ const this_=this; const date=new Date(); const _url=document.getElementById("iframe_"+this._route.name).src; let _path=_url+'?t='+date.getTime(); if(_url.indexOf('?')!= -1){ _path= (_url.substr(0,_url.indexOf('?')))+'?t='+date.getTime(); } document.getElementById("iframe_"+this._route.name).src=_path; } }, })

 

你可能感兴趣的:(Vue)