I need help using vue-ganttastic. It looks very good. But I can't make it work with Nuxt :frowning: I didn't have problems adopting other Vue3 modules into nuxt (like jodit or echarts). I even adopted vanilla js mgt ( microsoft draft toolkit). however I spent lots of time with this ganttastic without success.
Please help

推荐答案

以下是Nuxt3的基本配置.根据他们文档中的基本示例,不会出现任何问题 https://github.com/zunnzunn/vue-ganttastic#quickstart

npm install @infectoone/vue-ganttastic

要全局安装它,您需要将其添加为插件.

ganttastic.client.ts

import ganttastic from '@infectoone/vue-ganttastic'

export default defineNuxtPlugin((nuxtApp) => {
    nuxtApp.vueApp.use(ganttastic)
})

app.vue强中

<template>
  <div>
    <ClientOnly>
      <g-gantt-chart
        chart-start="2021-07-12 12:00"
        chart-end="2021-07-14 12:00"
        precision="hour"
        bar-start="myBeginDate"
        bar-end="myEndDate"
      >
        <g-gantt-row label="My row 1" :bars="row1BarList" />
        <g-gantt-row label="My row 2" :bars="row2BarList" />
      </g-gantt-chart>
    </ClientOnly>
  </div>
</template>

<script setup>
const row1BarList = ref([
  {
    myBeginDate: '2021-07-13 13:00',
    myEndDate: '2021-07-13 19:00',
    ganttBarConfig: {
      // each bar must have a nested ganttBarConfig object ...
      id: 'unique-id-1', // ... and a unique "id" property
      label: 'Lorem ipsum dolor',
    },
  },
]);
const row2BarList = ref([
  {
    myBeginDate: '2021-07-13 00:00',
    myEndDate: '2021-07-14 02:00',
    ganttBarConfig: {
      id: 'another-unique-id-2',
      hasHandles: true,
      label: 'Hey, look at me',
      style: {
        // arbitrary CSS styling for your bar
        background: '#e09b69',
        borderRadius: '20px',
        color: 'black',
      },
    },
  },
]);
</script>

希望这对你有帮助.

此处的工作示例 https://stackblitz.com/edit/nuxt-starter-5gc98q?file=app.vue

Vue.js相关问答推荐

Nuxt3: 安装vue3-spinner (error: require is not defined in ES module scope)

在移动版本中使用标准的 v-data-table

v-on 的 .native 修饰符仅在组件上有效,但在 标签上使用

如何在 vue 组件中定义变量? (Vue.JS 2)

如何在 vue 组件之外访问$apollo?

Vue + Webpack 构建显示空白页面

为什么在 Vue.js 中使用 `var` 关键字?

VueJS 插件的如何react式绑定?

如何在 Vue 中编译从外部 api 加载的模板

Vue.js 中的 mount挂载是什么意思?

将自定义部分添加到 v-autocomplete 下拉列表

axios.patch / axios.put 在 Vue 和 Laravel 中不起作用

如何使表格行可点击并展开行 - vue.js - element-ui

Vue 组件 Vue-Instant

Proxy代理在 Vue 3 的控制台中是什么意思?

基于条件的VueJS HTML元素类型

Vue组件未在laravel 5.3中使用Passport 显示

执行调度程序刷新期间未处理的错误,这可能是一个 Vue 内部错误

vue-cli-service build --target lib 导入为 lib 时丢失图像路径

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