石家庄购物网站排名,蓝海国际版网站建设,网站建设资讯,软文街怎么样Cannot use import statement outside a module
原因#xff1a;在commonJS中用了es6的语法#xff0c;import。分析#xff1a; 一般我们的运行环境按照模块化标准来分#xff0c;可以分为es6和commonJS两种#xff0c;在es6中引入模块用import#xff0c;在commonJS中…Cannot use import statement outside a module
原因在commonJS中用了es6的语法import。分析 一般我们的运行环境按照模块化标准来分可以分为es6和commonJS两种在es6中引入模块用import在commonJS中用require。在你的环境中全局下输出this,如果指向的是undefined那么就是es6否则是commonJS解决方法 把文件改成.ts后缀或者import改成require
ERROR Invalid options in vue.config.js: “resolve“ is not allowed
原因在Vue CLI中webpack配置是通过webpack-merge来合并的而不是直接在vue.config.js中配置。分析两个文件可以共存都是用来声明配置的。只不过着重点不同vue.config.js声明vue项目的配置webpack.config.js声明全局的配置。至于出现了这个问题显然是因为在vue.config.js中使用了webpack.config.js的配置语法解决 下载webpack-merge 配置webpack.config.js:
const { merge } require(webpack-merge);
const defaultConfig require(vue/cli-service/webpack.config.js);
function resolve(p){return path.resolve(__dirname,p)
}
module.exports merge(defaultConfig, {// 自定义配置resolve:{alias:{:resolve(src)}}
});Unexpected console statement (no-console)
解决方法 创建文件.eslintrc.js
module.exports {rules: {no-console: off,no-restricted-syntax: [error,{selector: CallExpression[callee.object.nameconsole][callee.property.name!/^(log|warn|error|info|trace)$/],message: Unexpected property on console object was called}]}}app.use is not a function in vue (vue2)
const appnew Vue({render: h h(App),
})
app.use(plugin)
app.$mount(#app) // 为什么会报错app.use is not a function在Vue中使用插件需要在创建Vue实例之前调用Vue.use(plugin)。
Vue.use(plugin)const app new Vue({render: h h(App),
})app.$mount(#app)