Node.js/nuxt:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
Kangkk​(留言 | 贡献)
 
(未显示同一用户的15个中间版本)
第47行: 第47行:
{| class="wikitable"
{| class="wikitable"
|-
|-
| [[/传值|传值]] || [[/路由|路由]] || [[/跨域|跨域]]
| [[/传值|传值]] || [[/路由|路由]] || [[/跨域|跨域]] || [[/token|token]] || [[/代码打包|代码打包]]
|-
|-
| [[/全局变量|全局变量]] || [[/生命周期|生命周期]] || 示例
| [[/全局变量|全局变量]] || [[/生命周期|生命周期]] || [[/session|session]] || [[/css module|css module]]
|-
|-
| 示例 || 示例 || 示例
| [[/导入css样式|导入css样式]] || [[/其他|其他]] || [[/骨架屏|骨架屏]] || [[/组件加载方式|组件加载方式]]
|}
|}


第57行: 第57行:
{| class="wikitable"
{| class="wikitable"
|-
|-
| [[/debugger|debugger]] || [[/mockjs|mockjs]] || 示例
| [[/debugger|debugger]] || [[/mockjs|mockjs]] || [[/plugin参数|plugin参数]]
|-
|-
| 示例 || 示例 || 示例
| 示例 || 示例 || 示例
第115行: 第115行:
* [Function (anonymous)]
* [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>