Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

vue的路由跳转问题

现在有个输入框,默认或为空的时候是历史搜索页面,输入的时候下面同时出现联想词,这两个还是搜索页面的子路由,我用的是@input时间,this.$router.push,这样就直接跳的是父页面,怎么只让子页面的路由跳转呢,还有放到@input里会不会太频繁跳转页面,输入一次就跳转一次### 问题描述


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

你的组件结构跟你的路由结构对应就能只跳转子页面

// search.vue
 <template>
    <input />
    <router-view />
 </template>
 <script>
    export default {
        name: 'search',
        methods: {
            navigate() {
                this.$router.push('/search/list?keyword=')
            }
        }
    }
 </script>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...