mpvue项目集成mpvue-router-patch插件实现路由跳转

github地址:https://github.com/F-loat/mpvue-router-patch

安装依赖

cnpm i -S mpvue-router-patch

在main.js里安装插件

import MpvueRouterPatch from 'mpvue-router-patch'

Vue.use(MpvueRouterPatch)

在页面使用

<template>
  <div>

    <div class="text">
      ibook
    </div>

    <van-button type="primary" @click="jump">按钮</van-button>

  </div>

</template>

<script>

export default {
  methods:{
    jump(){
      this.$router.push('/pages/index/main')

    }
  }

}
</script>

<style lang="scss" scoped>
.text{
  color: red;
}
</style>

至此,路由跳转插件就集成完毕了

注意
1、this.$router.push('/pages/index/main')是跳转到下个页面,不关闭当前页面。

2、this.$router.replace('/pages/index/main')是跳转到下个页面,并且关闭当前页面。

作者:_小三爷
链接://www.greatytc.com/p/356e318bca83
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。