uniapp 监听手机返回上一页

 

tempalte

<div class="mytop">
      <cmd-icon class="myReturn" type="chevron-left" size="30" color="#fff" @click="onreturn()"></cmd-icon>
      <p class="myReturntitle">个人资料</p>
    </div>

script

data() {
    return {};
  },
  onBackPress(options) {
    if (options.from === \'navigateBack\') {
      return false;
    }
    this.onreturn();
    return true;
  },
  methods: {
 // 返回上一页
    onreturn() {
      uni.reLaunch({
        url: \'user\'
      });
    },
}