代码中使用了path.resolve()——出现error ‘path‘ is not defined no-undef这种报错的【解决方法】

当前这个Vue2项目中使用了path.resolve()

path.resolve()——将[路径path/路径path片段的序列] [进行拼接]。零长度的 path片段被忽略。

参考:

path.resolve([...paths]) | Node.js API 文档

```

比如:

path.resolve('/foo/bar', './baz');

// 返回: '/foo/bar/baz'

path.resolve('/foo/bar', '/tmp/file/');

// 返回: '/tmp/file'

path.resolve('wwwroot', 'static_files/png/', '../gif/image.gif');

// 如果当前工作目录是 /home/myself/node,

// 则返回 '/home/myself/node/wwwroot/static_files/gif/image.gif'

```

代码中使用了path.resolve()——出现error ‘path‘ is not defined no-undef这种报错的【解决方法】_第1张图片

但是,当前cmd中输入yarn start,回车——启动项目的时候,出现以下报错 

代码中使用了path.resolve()——出现error ‘path‘ is not defined no-undef这种报错的【解决方法】_第2张图片

解决方法:

script中export default上面添加以下内容:

import path from "path";

 代码中使用了path.resolve()——出现error ‘path‘ is not defined no-undef这种报错的【解决方法】_第3张图片

 

实现效果:

以上报错消失

代码中使用了path.resolve()——出现error ‘path‘ is not defined no-undef这种报错的【解决方法】_第4张图片

你可能感兴趣的:(报错解决,前端,开发语言,vue.js)