文件
<template> <div id="app"> <h2>{{hello}}:{{animal.name}}</h2> </div> </template> <script> export default { name: "app", data: () => { return { hello: "你好", animal: {} }; }, mounted() { setTimeout(() => { this.$set(this.animal, "name", "大象?"); }, 3000); } }; </script> <style> #app { color: gold; } </style>
效果
添加前:
添加后: