Node.js/nuxt:修订间差异
来自康健生活
| (未显示同一用户的23个中间版本) | |||
| 第3行: | 第3行: | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
| [[/target|target]] || [[/modern|modern]] || | | [[/target|target]] || [[/modern|modern]] || [[/axios|axios]] | ||
|- | |- | ||
| | | [[/asyncData|asyncData]] || 示例 || 示例 | ||
|- | |- | ||
| 示例 || 示例 || 示例 | | 示例 || 示例 || 示例 | ||
| 第47行: | 第47行: | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
| [[/传值|传值]] || [[/路由|路由]] || [[/跨域|跨域]] | | [[/传值|传值]] || [[/路由|路由]] || [[/跨域|跨域]] || [[/token|token]] || [[/代码打包|代码打包]] | ||
|- | |- | ||
| [[/全局变量|全局变量]] || | | [[/全局变量|全局变量]] || [[/生命周期|生命周期]] || [[/session|session]] || [[/css module|css module]] | ||
|- | |- | ||
| | | [[/导入css样式|导入css样式]] || [[/其他|其他]] || [[/骨架屏|骨架屏]] || [[/组件加载方式|组件加载方式]] | ||
|} | |} | ||
== 调试 == | == 调试 == | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
| [[/debugger|debugger]] || | | [[/debugger|debugger]] || [[/mockjs|mockjs]] || [[/plugin参数|plugin参数]] | ||
|- | |- | ||
| 示例 || 示例 || 示例 | | 示例 || 示例 || 示例 | ||
| 第107行: | 第108行: | ||
}</syntaxhighlight> | }</syntaxhighlight> | ||
* Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension. | * Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension. | ||
* getaddrinfo ENOTFOUND | |||
*: DNS 解析问题,我抛出的是 <code>getaddrinfo ENOTFOUND apiv2.chu***.cn</code> 的错误,只需要在本地 hosts 文件夹里将 <code>apiv2.chu***.cn</code> 的解析地址填入即可。 | |||
*: <syntaxhighlight lang="javascript"> | |||
39.***.***.*** apiv2.chu***.cn</syntaxhighlight> | |||
*: 这里需要说明的是,因为项目需求,<code>apiv2.chu***.cn</code> 并不是实际的域名,也就是说它只是一个自定义的字段,需要在 DNS 服务器解析。 | |||
* [Function (anonymous)] | |||
*: 匿名函数 | |||
* Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "whetherJumpUploadInfo" | |||
*: 通过 props 传递给子组件的 whetherJumpUploadInfo,不能在子组件内部修改 props 中的 whetherJumpUploadInfo 值。 | |||
*:<syntaxhighlight lang="html5"> | |||
父组件 | |||
<div :whetherJumpUploadInfo="whetherJumpUploadInfo" @jumpUploadInfo="jumpUploadInfoFn"></div> | |||
子组件 | |||
<template> | |||
... | |||
</template> | |||
<script> | |||
export default { | |||
... | |||
props: { | |||
whetherJumpUploadInfo: { | |||
type: Boolean, | |||
default: () => false | |||
} | |||
}, | |||
methods:{ | |||
uploadOnProgress (){ | |||
// this.whetherJumpUploadInfo = true | |||
this.$emit('jumpUploadInfo'); //通知父组件改变 | |||
} | |||
} | |||
}</syntaxhighlight> | |||
* omputed property "fileList" was assigned to but it has no setter. | |||
*: <syntaxhighlight lang="javascript"> | |||
fileList: { | |||
get () { | |||
return this.$store.state.file.fileList; | |||
}, | |||
set (val) { | |||
this.$store.state.file.fileList = val; | |||
} | |||
} | |||
</syntaxhighlight> | |||
* client.js?06a0:97 Error: [vuex] do not mutate vuex store state outside mutation handlers. | |||
*: 不能直接修改 state,原码: | |||
*: <syntaxhighlight lang="javascript"> | |||
computed: { | |||
fileList: { | |||
get() { | |||
return this.$store.state.file.fileList | |||
}, | |||
set(fileItem) { | |||
this.$store.dispatch('file/addFile', fileItem) | |||
} | |||
} | |||
},</syntaxhighlight> | |||
*: 修改如下 | |||
*: <syntaxhighlight lang="javascript"> | |||
computed: { | |||
fileList: { | |||
get() { | |||
return this.$store.state.file.fileList.slice() | |||
}, | |||
set(fileItem) { | |||
this.$store.dispatch('file/addFile', fileItem) | |||
} | |||
} | |||
},</syntaxhighlight> | |||
* Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "fileList" | |||
:* 原码 | |||
:* <syntaxhighlight lang="javascript"> | |||
mounted() { | |||
Object.assign(this, this.$store.state.file) | |||
this.fetchResourceResTagRecom('cs'); | |||
},</syntaxhighlight> | |||
:* <syntaxhighlight lang="javascript"> | |||
mounted() { | |||
Object.assign({}, this, this.$store.state.file) | |||
this.fetchResourceResTagRecom('cs'); | |||
},</syntaxhighlight> | |||