Directly modifying the value in props in vue does not give a warning. Why?

when explaining the one-way data flow of props, the vue official website mentioned:

in addition, each time the parent component is updated, all prop in the child component will be refreshed to the latest value. This means that you should not change the prop within a subcomponent. If you do, Vue will issue a warning in the browser"s console.

but I tested and directly modified the value of props without giving any warning.
have you met anyone?

Apr.07,2021

? Here comes Chestnut, please check

parent component
<template>
    <div>
        <child :data="data" :obj="obj"/>
        <h1>data: {{data}}</h1>
        <h1>objData: {{obj.data}}</h1>
    </div>
</template>

<script>
import child from './child'
export default {
    data(){
        return {
            data: '',
            obj: {
                data: ''
            }
        }
    },
    components: { child }
}
</script>
subcomponents
<template>
    <div>
        <button @click="change">click to change prop data</button>
        <button @click="changeObjData">click to chnage prop objData</button>
    </div>
</template>
<script>
export default {
    props: ['data', 'obj'],
    methods: {
        change(){
            this.data = Math.random()
        },
        changeObjData(){
            this.obj.data = Math.random()
        }
    }
}
</script>

two buttons, one is prop that changes the value type, and the other is prop that changes the reference type of . You will find that the first button will report an error and the value will not be changed, but when you press the second button, the value will change and no error will be reported. That is because what your parent component passes is only a reference. To put it bluntly, it passes a memory address (pointer), and the child component changes the above value. The pointer is not changed, so the system assumes that it does not cause a change in the value of the parent component, so there is no error prompt.


move on

 prop :

Prop ;

Prop 

:

 prop :

props: ['initialCounter'],
data: function () {
  return { counter: this.initialCounter }
}
 prop :

props: ['size'],
computed: {
  normalizedSize: function () {
    return this.size.trim().toLowerCase()
  }
}

if the value passed in by props is a reference type, change its element in the child component without changing the reference, then no error is reported.
if it is an ordinary type, then the browser console will report an error message when modifying


one-way data browsing does not allow you to modify. If you can modify it, each component can operate on the data, so it cannot effectively track the changes of the data

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e59e3e-45586.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e59e3e-45586.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?