在 Vuetify Stepper 内部时,Handsontable 不会立即显示

标签 handsontable vuetify.js

将 Handsontable HotTable 组件放置在 Vuetify Stepper 中时,Handsontable 仅在您单击页面上的某处后可见。但是,如果我将 HotTable 组件放在 Stepper 之外,它将立即显示。它应该立即在步骤 1 中可见。

为了演示这种意外行为,我在 CodePen 上 fork 了 Vuetify Stepper 示例并添加了“handsontable”和“@handsontable/vue”。

Vuetify Stepper with Handsontable on CodePen

<div id="app">
  <v-app id="inspire">
    <v-stepper v-model="e1">
      <v-stepper-header>
        <v-stepper-step :complete="e1 > 1" step="1">Name of step 1</v-stepper-step>
        <v-divider></v-divider>
        <v-stepper-step :complete="e1 > 2" step="2">Name of step 2</v-stepper-step>
        <v-divider></v-divider>
        <v-stepper-step step="3">Name of step 3</v-stepper-step>
      </v-stepper-header>
      <v-stepper-items>
        <v-stepper-content step="1">
          <v-card
            class="mb-5"
            color="grey lighten-1"
            height="200px"
          >
            <div id="hot-preview">
              <hot-table :settings="hotSettings"></hot-table>
            </div>
          </v-card>
          <v-btn
            color="primary"
            @click="e1 = 2"
          >
            Continue
          </v-btn>
          <v-btn flat>Cancel</v-btn>
        </v-stepper-content>
        <v-stepper-content step="2">
          <v-card
            class="mb-5"
            color="grey lighten-1"
            height="200px"
          ></v-card>
          <v-btn
            color="primary"
            @click="e1 = 3"
          >
            Continue
          </v-btn>
          <v-btn flat>Cancel</v-btn>
        </v-stepper-content>
        <v-stepper-content step="3">
          <v-card
            class="mb-5"
            color="grey lighten-1"
            height="200px"
          ></v-card>
          <v-btn
            color="primary"
            @click="e1 = 1"
          >
            Continue
          </v-btn>
          <v-btn flat>Cancel</v-btn>
        </v-stepper-content>
      </v-stepper-items>
    </v-stepper>
  </v-app>
</div>

new Vue({
  el: '#app',
  data () {
    return {
      e1: 0,
      hotSettings: {
        data: Handsontable.helper.createEmptySpreadsheetData(1, 8),
        colHeaders: true,
        rowHeaders: true
      }
    }
  },
  components: {
    HotTable
  }
});

最佳答案

我认为问题是因为您在安装组件之前对其进行了初始化。
尝试在 mounted 钩子(Hook)中初始化它:

hotSettings: {
    data: null,

//...

mounted() {
    this.hotSettings.data = Handsontable.helper.createEmptySpreadsheetData(1, 8)
}

关于在 Vuetify Stepper 内部时,Handsontable 不会立即显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52006849/

相关文章:

vuetify.js - 消除 Vuetify 中无样式内容的闪现

vue.js - 如何将 Vuetify <v-card> 链接到外部网站?

javascript - 如何创建动态表单vuejs vuetify?

javascript - float 操作按钮重叠

php - 如何使用 jQuery 将数据从 PHP 加载到 Handsontable?

javascript - 如何选择handsontable中的所有复选框

javascript - 如何发送带有公式字段的handsontable

javascript - 下拉列表中的数组(Handsontable)

javascript - 方便的自动完成项目排序

vuejs2 - 如何在 v-radio 标签中设置 HTML