Node.js/nuxt:修订间差异
来自康健生活
< Node.js
| 第69行: | 第69行: | ||
*: key值不唯一 | *: key值不唯一 | ||
* Error: Avoided redundant navigation to current location: | * Error: Avoided redundant navigation to current location: | ||
*: | *: 路由重复,<code>this.$router.replace</code> 抛出错误。 | ||
*: <syntaxhighlight lang="javascript"> | *: <syntaxhighlight lang="javascript"> | ||
// this.$router.replace('/search?pageView=SearchAll&q=' + this.searchValue) | // this.$router.replace('/search?pageView=SearchAll&q=' + this.searchValue) | ||
this.$router.push('/search?pageView=SearchAll&q=' + this.searchValue)</syntaxhighlight> | this.$router.push('/search?pageView=SearchAll&q=' + this.searchValue)</syntaxhighlight> | ||
*: 或者直接更改文件重写 <code>this.$router.replace</code> 方法。 | |||
*: 在 router.js 文件 | |||
*: <syntaxhighlight lang="javascript"> | |||
/** | |||
* @author kangkk | |||
* @date 2020/7/15 | |||
* @description 禁止 router.replace 方法在路由指向上一次相同地址时抛出 Error: Avoided redundant navigation to current location | |||
*/ | |||
// eslint-disable-next-line no-proto | |||
const originalPush = router.__proto__.replace | |||
// eslint-disable-next-line no-proto | |||
router.__proto__.replace = function replace (location) { | |||
return originalPush.call(this, location).catch(err => err) | |||
}</syntaxhighlight> | |||
2020年7月15日 (三) 09:11的版本
引言
内存
npm install heapdump --save-dev
nuxt.config.js
var headpdump = require('heapdump')
setInterval(function () {
console.log('st headpdump')
headpdump.writeSnapshot(function(err, filename) {
console.log('dump written to', filename)
})
}, 15000)
打开 chrome 浏览器开发者工具 memory 选项卡,点击加载 hepdump。
目录结构
assets // 用于组织未编译的静态资源如LESS、SASS或JavaScript components // 用于自己编写的Vue组件,比如波动组件、日历组件、分页组件 layouts // 布局目录,用于组织应用的布局组件,不可更改 middleware // 用于存放中间件 pages // 用于存放写的页面,我们主要的工作区域 plugins // 用于存放JavaScript插件的地方 static // 用于存放静态资源文件,比如图片 store // 用于组织应用的Vuex 状态管理 .nuxt // Nuxt自动生成,临时的用于编辑的文件,build .editorconfig // 开发工具格式配置 .eslintrc.js // ESLint的配置文件,用于检查代码格式 .gitignore // 配置git不上传的文件 nuxt.config.json // 用于组织Nuxt.js应用的个性化配置,已覆盖默认配置 package-lock.json // npm自动生成,用于帮助package的统一设置的,yarn也有相同的操作 package.json // npm 包管理配置文件
关键词
| 传值 | 示例 | 示例 |
| 示例 | 示例 | 示例 |
| 示例 | 示例 | 示例 |
error
- Renderer resources are not loaded! Please check possible console errors and ensure dis
- 配置项有问题
- ENOSPC: System limit for number of file watchers reached, watch
- 系统监听数上限
- error Unable to resolve path to module '@@/pages/search/navmenu.vue' import/no-unresolved
npm i --save-dev eslint-import-resolver-alias
settings: { 'import/resolver': { alias: { map: [ ['@', './'], ['@@', './'], ['~', './'], ['~~', './'], ], } } },
- Duplicate keys detected: '/search'. This may cause an update error.
- key值不唯一
- Error: Avoided redundant navigation to current location:
- 路由重复,
this.$router.replace抛出错误。 // this.$router.replace('/search?pageView=SearchAll&q=' + this.searchValue) this.$router.push('/search?pageView=SearchAll&q=' + this.searchValue)
- 或者直接更改文件重写
this.$router.replace方法。 - 在 router.js 文件
/** * @author kangkk * @date 2020/7/15 * @description 禁止 router.replace 方法在路由指向上一次相同地址时抛出 Error: Avoided redundant navigation to current location */ // eslint-disable-next-line no-proto const originalPush = router.__proto__.replace // eslint-disable-next-line no-proto router.__proto__.replace = function replace (location) { return originalPush.call(this, location).catch(err => err) }
- 路由重复,
No categories