Node.js/nuxt

来自康健生活
Kangkk​(留言 | 贡献)2020年7月23日 (四) 11:57的版本 (→关键词)

引言

参数

target modern 示例
示例 示例 示例
示例 示例 示例

内存

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)
      }
    
  • Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.