我一直试图弄清楚如何console.log('whatever')在我的方法中学习一些 VueJs 开发,以了解我在这里所做的任何事情的一些行为。
我知道这里已经提出了一些问题,并且已经将范围纳入ESLINT文档以尝试解决这个问题......我实际上无法理解我应该做什么。
我的代码:
methods: {
submitData() {
this.$http.post('https://vue-testing-8a2de.firebaseio.com/data.json', this.user)
.then(response => {
console.log(response);
}, error => {
console.log(error)
})
}
}
Run Code Online (Sandbox Code Playgroud)
这是 ESLINT 上的错误:
Failed to compile.
./src/App.vue
Module Error (from ./node_modules/eslint-loader/index.js):
error: Unexpected console statement (no-console) at src/App.vue:35:22:
33 | this.$http.post('https://vue-testing-8a2de.firebaseio.com/data.json',this.user)
34 | .then(response => {
> 35 | console.log(response);
| ^
36 | }, error => {
37 | console.log(error)
38 | })
error: Unexpected console statement (no-console) at src/App.vue:37:22:
35 | …Run Code Online (Sandbox Code Playgroud) 我会让它变得简单:
关联: http://localhost:3000/product/bioCloths?activeCategory=medium&id=0
文件路径:pages/product/[product].js.
预期的: product: "bioCloths, activeCategory: "medium", id: "0"
使用getStaticProps在[product].js:
const ProductDetails = (props) => {
console.log("initial props", props);
return <div>product details...</div>
};
export default ProductDetails;
export async function getStaticProps(context) {
return {
props: {
context: context
},
};
}
export async function getStaticPaths() {
return {
paths: [{ params: { product: "1" } }, { params: { product: "2" } }],
fallback: true,
};
}
Run Code Online (Sandbox Code Playgroud)
Props返回:context: params: product: "bioCloths" …
环境:
NextJs、React、VsCode
我已经安装了以下扩展:
对我的配置文件做了以下操作json:
"files.associations": {
"*.js": "javascriptreact",
"*.env.development": "env",
"*.env.production": "env",
"*.env.local": "env",
},
Run Code Online (Sandbox Code Playgroud)
.env.local.example
我测试了一个公共变量NEXT_PUBLIC_ENV_LOCAL_VARIABLE = "Some public stuff",当我在浏览器上测试它时它不起作用。当我将终止添加.example到.env.local文件时,Vscode 完全停止识别该文件。
谢谢您的帮助