账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    vue + cube-ui 初始化报错 "export 'default' …… was not found
    37
    0

    按照官方文档安装

    npm run dev

    的时候报错

     WARNING  Compiled with 1 warnings                                                                                                                                                                  21:20:25
     warning  in ./src/main.js
    
    9:8-12 "export 'default' (imported as 'Cube') was not found in 'cube-ui'

    vue-cli 的版本

    npm info vue-cli
    
    vue-cli@2.9.6 | MIT | deps: 20 | versions: 35

    类似的问题

    https://github.com/cube-ui/qu...

    https://segmentfault.com/q/10...

    https://stackoverflow.com/que...

    都无解

    改成

    import * as Cube from 'cube-ui';
    Vue.use(Cube);

    倒是不报错了,但是插件都没注册了……

    1
    打赏
    收藏
    点击回答
    您的回答被采纳后将获得:提问者悬赏的 11 元积分
        全部回答
    • 共 0 条
    • 这个错误通常发生在尝试使用Vue框架和Cube-UI库初始化项目时。它表示在使用Vue组件时,引入了"export 'default' ",但未找到相关的文件或模块。

      "export 'default'" 是在Vue中使用的一种特殊导出方法,它用于向全局注册组件。如果没有使用"export 'default'",Vue的组件实例将无法在项目中使用。

      以下是一些可能的原因和解决方法:

      1. 检查导入:确保你在正确的文件或模块中导入了"export 'default'"。例如,如果你的组件位于名为 "my-component.vue" 的文件中,你可以这样做:

      html <cube-ui :options="myOptions"></cube-ui>

      如果导入在 "my-component.js" 文件中,你需要将 "export 'default'" 替换为 "import 'cube-ui' from 'my-component'"。

      1. 检查路径:确保你的导入文件在你的项目的目录中。例如,如果你的 "my-component.js" 文件在 "src/components" 目录下,你需要将 "import 'cube-ui' from 'my-component'" 替换为 "import cube-ui from './components/my-component'"。

      2. 检查模块名:确保你导入的模块名正确。例如,如果你的模块名为 "my-component",你需要将 "import cube-ui from './components/my-component'" 替换为 "import cube-ui from 'my-component'"。

      3. 检查组件名:确保你的组件名正确。例如,如果你的组件名为 "my-component",你需要将 "import cube-ui from './components/my-component'" 替换为 "import cube-ui from 'my-component'"。

      4. 使用相对路径:如果你的组件位于项目的其他位置,你可以使用相对路径。例如,如果你的组件位于 "src/components/my-component" 目录下,你可以使用 "import cube-ui from './components/my-component'"。

      希望这些建议对你有所帮助!如果你仍然遇到问题,你可以尝试重新安装组件库或查阅Cube-UI的官方文档。

    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部