Nuxt插件在构建后无法使用(使用apexchart)

问题描述 投票:0回答:1

我在nuxt中使用顶点图并用我的代码应用插件在开发模式下工作

cross-env NODE_ENV=development HOST=0.0.0.0 PORT=3000 nodemon server/index.js --watch server

但不能在构建源中使用

nuxt build && cross-env NODE_ENV=production HOST=0.0.0.0 PORT=80 node server/index.js

这是我的密码插件/vue-apexchar.js

import Vue from 'vue'
import VueApexCharts from 'vue-apexcharts'

Vue.component('VueApexCharts', VueApexCharts);

nuxt.config.js

plugins: [
    { src : '~/plugins/vue-apexchart.js', ssr : false },
],
build: {
  vendor : [
     'vue-apexchart'
  ]
}

weekChart.vue

<VueApexCharts max-width="300" type="area" :options="chartOptions" :series="series"></VueApexCharts>

这些代码在开发人员模式下有效,但在构建文件中无效我需要您的帮助来解决这个问题请帮我这是我的源代码> https://github.com/zoz0312/Nuxt_Blog

nuxt apexcharts
1个回答
0
投票
<client-only>
    <MY COMPONENT/>
</client-only>

使用“仅客户端”标签可解决此问题“此组件用于故意仅在客户端上呈现组件。”我的插件只能在客户端使用,因此请使用该标签,我可以解决此问题

© www.soinside.com 2019 - 2024. All rights reserved.