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

2020-03-31  本文已影响0人  猪猪侠闯天下

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')是跳转到下个页面,并且关闭当前页面。

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

上一篇 下一篇

猜你喜欢

热点阅读