欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

解決vue 子組件修改父組件傳來(lái)的props值報(bào)錯(cuò)問題

 更新時(shí)間:2019年11月09日 09:33:59   作者:254980080  
今天小編就為大家分享一篇解決vue 子組件修改父組件傳來(lái)的props值報(bào)錯(cuò)問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來(lái)看看吧

vue不推薦直接在子組件中修改父組件傳來(lái)的props的值,會(huì)報(bào)錯(cuò)

[Vue warn]: 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: "result" (found in component )

 <input v-model="currentSearch" type="text" class="input-search" @keydown.enter="doSearch">
export default {
  name:"round-search-bar",
  props:['search'],  //父組件傳來(lái)的值
  data(){
    return {
      currentSearch: this.search  //通過data, 定義新變量currentSearch, 這樣currentSearch的值變更時(shí),不會(huì)影響父組件傳來(lái)的search的值
    }
  },
  methods: {
    doSearch(){
      Util.searchAPI(this.$router,this.currentSearch)
    }
  },
}

以上這篇解決vue 子組件修改父組件傳來(lái)的props值報(bào)錯(cuò)問題就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論