我试图disable Vuetify V-Stepper Actions像如果它是在第一步previous按钮将被禁用和next按钮将被禁用时,它到达最后一步.顺便说一句,我正在使用Vuetify 3和Nuxt 3,这里是我的代码

<template>
  <section class="p-10">
    <v-stepper
      :items="headerItems"
      rounded="0"
      theme="light"
      ref="stepper"
      elevation="0"
      selected-class="selected-item"
    >
      <template v-slot:item.1>
        <p>Page 1</p>
      </template>

      <template v-slot:item.2>
        <p>Page 2</p>
      </template>

      <template v-slot:item.3>
        <p>Page 3</p>
      </template>

      <template v-slot:item.4>
        <p>Page 4</p>
      </template>

      <template v-slot:actions>
        <section class="flex justify-end items-center space-x-4 pt-10">
          <v-btn @click="stepper.prev()" size="large" variant="outlined">
            <p class="text-[18px] font-medium capitalize tracking-wide">Previous</p>
          </v-btn>
          <v-btn @click="stepper.next()" size="large" variant="flat" color="primary" theme="dark">
            <p class="text-[18px] font-medium capitalize tracking-wide">Next</p>
          </v-btn>
        </section>
      </template>
    </v-stepper>
  </section>
</template>

<script setup>
const stepper = ref(null);
const headerItems = ref(["Step 1", "Step 2", "Step 3", "Step 4"]);
</script>

<style scoped>
/* Custom styles here */
</style>

我试着做:disabled="stepper.activeStep === 0"v-btn,但它不工作的前一个和下一个按钮.

推荐答案

正如另外comment个建议的那样,添加一个v模型,然后禁用它将是最简单的方法:

v-model="page"

对于"上一步"按钮,请使用::disabled="page === 1"

对于Next按钮,请使用此选项::disabled="page === headerItems.length"

Vue.js相关问答推荐

在Nuxt项目中混合Scrolltrigger与Lenis

无法从CDN使用Vue和PrimeVue呈现DataTable

在vuejs中使用表单追加时如何使用布尔值

如何使用 vuejs 在浏览器 url 中获取当前 product.id 的详细信息

Vue CLI - 编译后将配置文件保留为外部

如何在 vuejs 自定义指令中传递动态参数

在 jest document.querySelector 中测试 vue 组件期间始终返回 null

如何将对象作为props传递并让组件更新子对象

使用 Vue 和 JS 下载 CSV 文件

如何将Vue的主应用程序渲染到body元素?

包含 Vue.js v-if 和 v-for 指令的 HTML 标签在加载时flash

vuex: unknown getter: user

如何使用 vuejs 从 SPA 访问 /storage -laravel- 中的图像

使用props向组件添加类名

即使在生产模式下构建,VueJS 也会显示开发模式开发模式消息

依赖关系甚至在 package.json 和 node_modules 中都没有定义

Vue.js react性如何在幕后工作?

vue 未在实例上定义,但在渲染期间引用

使用 Vee-validate 禁用按钮,直到正确填写表单

如何订阅store 模块