4

我在 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


这是我的代码

plugins/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'
  ]
}


周图.vue

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

这些代码在开发模式下工作但不能工作构建文件
我需要你的帮助来解决这个问题
请帮助我
这是我的源代码> https://github.com/zoz0312/Nuxt_Blog

4

1 回答 1

7
<client-only>
    <MY COMPONENT/>
</client-only>

使用'client-only'标签解决了这个问题

“这个组件是用来故意渲染一个组件只在客户端。”
我的插件只在客户端工作,所以使用那个标签,我可以解决这个问题

于 2019-11-10T12:13:57.243 回答