1.0.25 • Published 1 year ago

nuxt-error-page-module v1.0.25

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

说明

1.美化 nuxt 的错误提示页面,按照自己的业务进行定制 2.在生产环境,更加详细的提示错误堆栈信息

使用方法

nuxt.config.js 中以 module 的方式引入:

 modules: [
    ['nuxt-error-page-module',{
      //支持以下扩展选项,全部为可选
      templateFilePath:path.join(__dirname,'./tpl/error.html'),
      errorMsg:{
        MSG_404:'页面不存在',
      }
    }]
  ],
  1. 组件会自动捕获运行时异常信息并展示
  2. 如果要指定错误码和错误信息,可以在页面中使用如下方式:
export default {
  async asyncData({ $content }) {
    throw new Error(
      JSON.stringify({
        // 注意,这里一定要使用JSON.stringify!!!
        message: 'This is an error',
        statusCode: 404,
      })
    );
  },
};

自定义模板

支持使用自定义的模板

 modules: [
    ['nuxt-error-page-module',{templateFilePath:path.join(__dirname,'./tpl/error.html')}]
  ],

传入的模板使用 lodash.template 语法,可供使用的变量对象有:

errorInfo
nuxtOptions

模板语法可参考https://www.lodashjs.com/docs/lodash.template

1.0.25

1 year ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.5

2 years ago