首页 > Web开发 > 详细

vue.js使用select跳转页面

时间:2019-05-07 17:03:14      阅读:202      评论:0      收藏:0      [点我收藏+]
<div id="app">
    <select v-model="selected" @change="changeHref(parseInt(selected))"> 
      <!--selected需转换成数值型,否则不会响应-->
        <option value="1">第一张</option>
        <option value="2">第二张</option>
        <option value="3">第三张</option>
    </select>
</div>

  

<script>
export default {
  data(){
    return {
      selected:1, 
    }
  },
  methods:{
    changeHref:function(sortnum){
      switch(sortnum){
        case 1:
        this.$router.push({
          path:"/cityArea"
        });
        break;
        case 2:this.$router.push({
          path:"/otherArea"
        });
        break;
     case 3:this.$router.push({
          path:"/otherArea"
        });
        break;
} } } }; </script>

  

router.js   二级路由的引入,写的不详细,重点是跳转
import cityArea from ‘@/views/home/cityArea.vue‘
import otherArea from ‘@/views/home/otherArea.vue‘
const routes = [

 { 
  	 path: ‘/‘,
  	 component: Home,
  	  children: [
  	    {
          path: ‘/cityArea‘,
          component: cityArea
        },
        {
          path: ‘/otherArea‘,
          component: otherArea
        },

  	  ]
   },
]

  

vue.js使用select跳转页面

原文:https://www.cnblogs.com/chr506029589/p/10826057.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!