Article From:https://www.cnblogs.com/xuyxbiubiu/p/9968115.html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>VueMiddle set method & lt; / Title & gt;Script src=". / vue. js" & gt; & lt; / script & gt;Lt; / head & gt;< body>Div id= "app" & gt;<!--< div v-for="(item,key,index) of userInfo">-->
            <!--{{item}}-&#45;&#45;{{key}}-&#45;&#45;{{index}}-->
        <!--</div>               &lt;!&ndash;Loop objects & amp; ndash; & amp; gt; - - gt;< div v-for="(item,index) of userInfo1">
            {{item}}
        </div>               <!--Loop arrays - gt;< /div>Script & gt;var vm = new Vue({
            el:"#app",
            data:{
                // userInfo:{
                //     name:'alex',
                //     age:'27',
                //     gender:'male',
                //     salary:'secret'
                // }

                userInfo1:[1,2,3,4]
            }
        })
    </script>
</body>
</html>

<!--
Vue.set(vm.userInfo,'address','beijing')
This is when the data can be directly changed and rendered on the page without changing the address reference.Vm. $set (vm. userInfo,'address','beijing') The same effect can also be achieved.For lists, both of the above set usage can change data rendering on a Web page.Vue. set (vm. userInfo,1,5)
vm.$set(vm.userInfo,2,10)

-->

 

Link of this Article: Basic usage of set in Vue

Leave a Reply

Your email address will not be published. Required fields are marked *