vue.js - 将现有的 vue 项目转换为 nuxt.js
问题描述
我想将现有的 vuejs 项目转换为 nuxt.js 项目。为此,我创建了 nuxt.js 项目并将移动的文件移动到 nuxt 项目。我已复制 scr/view/layout 并粘贴到 layouts 文件夹中,vuex 将文件存储到 store 文件夹中。在 Layouts.vue 内部将这个标签更改为 this 。更新了 nuxt.config.js 文件,相应地添加了样式、模块和插件。更新了所有损坏的路径。
但是当我们尝试 npm run dev 时,它给出了错误。
错误示例
ERROR in ./assets/js/components/cookie.js
Module Error (from ./node_modules/eslint-loader/index.js):
ERROR in ./assets/js/components/cookie.js
Module Error (from ./node_modules/eslint-loader/index.js):
D:\VueJs-Projects\nuxtapp\assets\js\components\cookie.js
9:29 error Unnecessary escape character: \. no-useless-escape
9:37 error Unnecessary escape character: \( no-useless-escape
9:39 error Unnecessary escape character: \) no-useless-escape
9:41 error Unnecessary escape character: \[ no-useless-escape
9:47 error Unnecessary escape character: \/ no-useless-escape
9:49 error Unnecessary escape character: \+ no-useless-escape
✖ 6 problems (6 errors, 0 warnings)
[1]: https://i.stack.imgur.com/uCdLe.jpg
解决方案
这是因为您选择在 nuxt 应用程序中使用 ESLint,并且现有应用程序中的代码触发了“no-useless-escape”错误。
如果您知道发生错误的行(输出为您提供了此信息;看起来像 components 文件夹中 cookie.js 中的第 9 行是问题)您可以将该代码包装在以下内容中:
/* eslint-disable no-useless-escape */
...
some code
...
/* eslint-enable no-useless-escape */
但是,我建议您选择与 Vue 应用程序相同的 linter,否则您可能会遇到其他类似的错误。
推荐阅读
- keycloak - 从任何来源(身份提供者或用户联合)添加用户时订阅事件
- laravel - 无法将视图或路由发布到我的项目目录中
- postgresql - 尽管在列上缺少选择权,但仍删除行
- python - python中的工作功能但是我的测试仍然失败?
- python - 在 Python 中添加自开始日期以来的行
- c - 如何使scanf根据第一个字符停止从输入中读取?
- vba - 无法访问通过方法添加到自定义类中的集合的自定义对象
- javascript - 带有 try catch puppeteer 的无限循环
- karate - 从同一功能文件中的另一个场景调用常见场景,其中请求正文存储在空手道的 json 文件中
- javascript - 如何在本机反应中创建无限滚动?