【问题标题】:How to go back on click of a button from the .vue without opening a new window?如何在不打开新窗口的情况下从 .vue 单击按钮返回?
【发布时间】:2020-01-30 23:58:26
【问题描述】:

我正在尝试创建一个返回登录或重定向到/login 的按钮,目前我已经尝试使用el-buttoninertia-link 进行此操作,它们都可以工作,但不是我想要的喜欢。

这是我已经尝试让inertia-link 工作的代码:

<el-button-group style="margin-left: 53%; margin-bottom: 10px">
    <inertia-link class="el-button--info" :href="'/login'">
        <i class="fas fa-chevron-left"></i>
    </inertia-link>

    <el-button
        :type="getStatus()"
        :loading="loading"
        @click="submit()">Enviar Link
    </el-button>
</el-button-group>

代码el-button:

<el-button-group style="margin-left: 53%; margin-bottom: 10px">
    <el-button
        type="info"
        icon="fas fa-chevron-left"
        @click="redirect()"
>
    </el-button>

    <el-button
        :type="getStatus()"
        :loading="loading"
        @click="submit()">Enviar Link
    </el-button>
</el-button-group>


methods() {
    redirect(){ 
        window.open('/login');       
    }
}

使用inertia-link 很难看,如果我只输入class="el-button",该类看起来不正确,但我需要添加一个 el 按钮类型为info,我现在如何拥有它为@ 987654331@它不起作用。使用el-button 它会打开另一个选项卡,我想留在同一页面上,只需像inertia-link 那样转到登录页面即可。

【问题讨论】:

    标签: laravel element-ui inertiajs


    【解决方案1】:

    您可以使用 Inertia 中的 visit 方法:

    redirect() {
        this.$inertia.visit('/login');
    }
    

    由于某种原因,它已在文档中丢失,但您仍然可以在 Github 的历史记录中找到它:https://github.com/inertiajs/inertia-vue/tree/2c6da0ccb9b4f80c94650ba687cfad0073f3f0c2#manually-making-visits

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多