Vue 在引入外部js报错

时间:2025-04-21 17:39:23

**问题:**
在中引入

<script src="/jquery/1.10.2/"></script>


但是在组件中使用时,出现 xxx is not defined ( no-undef )是Eslint检查搞得鬼
**解决办法:**
在src下新建一个.,但是注意若已经在中配置了`lintOnSave:false`,则会冲突,具体原因未,然后在中加入

```
 = {
    root: true,
    env: {
        node: true
    },
    'extends': [
        'plugin:vue/essential',
        'eslint:recommended'
    ],
    rules: {
        'no-console': .NODE_ENV === 'production' ? 'error' : 'off',
        'no-debugger': .NODE_ENV === 'production' ? 'error' : 'off',
        'no-undef': 'off',
        'vue/no-unused-vars': 'off',
        'vue/require-v-for-key': 'off',
        'no-unused-vars': 'off',
        'vue/no-unused-components': 'off'
    },
    parserOptions: {
        parser: 'babel-eslint'
    }
};
```


[参考文章]