The vue child component modifies the value of the parent component

there are child components in parentheses. I click the button to pass true to the parent component to change its state, but the error says: avoid changing a PROP, directly because the value is overwritten every time the parent component is re-rendered.



export default{
  props: {
      onlyContent: {
        type: Boolean,
        default: false
      }
  },
  methods: {
      toggleContent (event) {
        if (!event._constructed) {
            return
        }
        this.onlyContent = !this.onlyContent
        this.$emit("contentToggle", this.onlyContent)
      }
  }
}


<v-ratingSelect v-on:contentToggle="contToggle" :only-content="onlyContent"></v-ratingSelect>

data () {
  return {
    onlyContent: false
  }
}

contToggle (event) {
  this.onlyContent = event
}
Mar.28,2021

modify onlyContent in the parent component

// 
toggleContent (event) {
    ...
    this.$emit('contentToggle')
}

// 
contToggle () {
  this.onlyContent = !this.onlyContent
}

this.onlyContent =! this.onlyContent , error, propvalue cannot be modified directly in subcomponents;
if you want to bind a prop bidirectionally, you can use the .sync modifier; just read the document; ide/components-custom-events.html-sharpsync-%E4%BF%AE%E9%A5%B0%E7%AC%A6" rel=" nofollow noreferrer "> sync

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-1b3eea1-2c443.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-1b3eea1-2c443.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?