【问题标题】:How to implement handsontable into nuxt.js如何在nuxt.js中实现handsontable
【发布时间】:2020-06-26 08:31:04
【问题描述】:

我正在尝试在我使用的项目上安装 handsontable

npm install handsontable @handsontable/vue

也许我需要创建一个插件? 如何在现有的 nuxt 项目中使用 handsontable?

【问题讨论】:

    标签: nuxt.js handsontable


    【解决方案1】:

    好的,我成功了。希望这可以帮助您并节省一些时间。

    1. 运行npm install handsontable @handsontable/vue
    2. plugins目录下创建一个文件名vue-handsontable.js,如下。
    const HotTable = !process.client ? null : require('@handsontable/vue').HotTable
    export default HotTable
    
    1. 打开 nuxt.config.js 并附加以下内容。
      build: {
        vendor: ['handsontable'],
      },
      plugins: [
        { src: '~/plugins/vue-handsontable', ssr: false },
      ]
    
    1. 转到您的模板文件并像这样放置行。
    <template>
      <HotTable :settings="settings" :data="data"></HotTable>
    </template>
    
    <script>
      import HotTable from '~/plugins/vue-handsontable'
    
      export default {
        data: function() {
          return {
            settings: {
              data: [
                ["", "Ford", "Volvo", "Toyota", "Honda"],
                ["2016", 10, 11, 12, 13],
                ["2017", 20, 11, 14, 13],
                ["2018", 30, 15, 12, 13]
              ],
              colHeaders: true,
              rowHeaders: true,
            }
          };
        },
        head: {
          link: [
            { rel: 'stylesheet', type: 'text/css', 
              href: '/your/path/to/css/directory/handsontable.full.min.css' },
          ]
        },
        components: {
          HotTable
        }
      }
    </script>
    

    祝你好运。

    修订版 1:

    自 Handsontable 7.0.0(2019 年 3 月发布)以来,许可证密钥是强制性的。

    settings: {
      data: [
        ["", "Ford", "Volvo", "Toyota", "Honda"],
        ["2016", 10, 11, 12, 13],
        ["2017", 20, 11, 14, 13],
        ["2018", 30, 15, 12, 13]
      ],
      rowHeaders: true,
      colHeaders: true,
      licenseKey: 'non-commercial-and-evaluation'
    }
    

    【讨论】:

      猜你喜欢
      • 2019-11-10
      • 2021-09-17
      • 2018-02-13
      • 2018-03-26
      • 1970-01-01
      • 2018-10-14
      • 2019-12-15
      • 2022-01-27
      • 2016-06-13
      相关资源
      最近更新 更多