【问题标题】:[Vue warn]: Error in render: "ReferenceError: File is not defined" [Vuetify + NuxtJS][Vue warn]: Error in render: "ReferenceError: File is not defined" [Vuetify + NuxtJS]
【发布时间】:2021-11-07 17:32:31
【问题描述】:

(我正在使用 Vuetify 和 NuxtJS)

我在尝试实现组件时收到此错误:v-file-input

文件.vue:

<template>
    <v-file-input
        counter
        multiple
        show-size
        truncate-length="15"
    ></v-file-input>
</template>

我只是在这个文件中遇到了这个问题,而不是在其他文件中。

当我从我的项目中复制粘贴一些其他代码到这个文件中时,如果我不修改它,它就可以工作。

知道为什么会这样吗?

【问题讨论】:

    标签: vue.js nuxt.js vuetify.js


    【解决方案1】:

    这是因为v-file-input 仅使用浏览器 API。

    你可以告诉 nuxt 用client-only 渲染这个唯一的客户端

    <client-only>
      <v-file-input
        counter
        multiple
        show-size
        truncate-length="15"
      ></v-file-input>
    </client-only>
    

    https://nuxtjs.org/docs/features/nuxt-components/#the-client-only-component

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-16
      • 2023-03-30
      • 2021-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-05
      • 2018-11-20
      相关资源
      最近更新 更多