vue 点击菜单跳转外部页面

主要使用 以下方式跳转外部页面,通过路由到指定页面后,再打开外部页面

1 window.location.href = 'http://www.baidu.com'

修改如下:

1.菜单配置 menu.js:

 1 let menu = {
 2     menus: [
 3 
 4         {
 5             key: '1', desc: '菜单1', icon: 'iconxxxx',  permission: 'xxxxx', subs: [
 6             {key: '/aaa/bbb',  desc: '菜单11', permission: 'xxxxx'},
 7             {key: '/aaa/bbb',  desc: '菜单12', permission: 'xxxxx'},
 8             {key: '/aaa/bbb',   desc: '菜单13', permission: 'xxxxx'},
 9             ]
10         },
11         {
12         // 需要跳转的外部链接
13             key: '/xxxxxx/outLink', desc: '外部链接', icon: 'iconxxxx',  permission: 'xxxxx',
14         }
15 
16     ]
17 };
18 
19 export default menu;

2.outLink.vue

 1 <template>
 2     <div>
 3 
 4     </div>
 5 </template>
 6 
 7 <script>
 8     import envs from '../../config/env'
 9     export default {
10         data () {
11             return {
12             }
13         },
14         methods: {
15         open(){
16             window.location.href = 'http://www.baidu.com';
17         },
18 
19         },
20         created () {
21             this.open();
22     }}
23 </script>

猜你喜欢

转载自www.cnblogs.com/whycai/p/12422029.html