The magical endless cycle of vue

< template >

<div id="testFirst">
    <h1>{{ msg }}</h1>
    <h1>{{ showDetail() }}</h1>
</div>

< / template >

< script >

/ / import Vue from "vue"

export default {

    name:"testFirst",
// }
// var vm=new Vue({
    //     el:"testFirst",
data () {
    return {
        msg: "hello  i am  lishang",
        state:"is it 404 not found"
    }
},
methods:{
    showDetail:function () {
        return this.state=this.msg+this.state
    }
}

}

< / script >

this is my error part of the code error displayed as You may have an infinite update loop in a component render function

when running, the showDetail function seems to loop an infinite number of times, and when I change it to
showDetail:function () {

        return this.state=this.msg+ "is  it 404 not found"   
        }
        
Mar.24,2021

just change it to the following

return this.msg+this.state
For

reason, < H1 > {{showDetail ()}} < / H1 > and this.state form a two-way binding, and then you assign a value to this.state when you showDetail return, so it triggers showDetail again to form an endless loop

.

this is not magical at all. The reason is explained on the first floor, but why do you put an execution function in your second H1? the correct one should be

.
 <h1>{{ showDetail }}</h1>
<script>
    computed: {
        showDetail() {
            return this.msg+this.state;
        }
    }
</script>

is not magical, just use the calculation attribute

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