JS-简单数据绑定-MVC 发表于 2018-01-20 一、视图层V1234<div> <p>你好,<span id='nickName'></span></p> <div id="introduce"></div></div> 二、视图控制器C123456789101112131415161718192021var userInfo = {};Object.defineProperty(userInfo, "nickName", { get: function() { return document.getElementById('nickName').innerHTML; }, set: function(nick) { document.getElementById('nickName').innerHTML = nick; }});Object.defineProperty(userInfo, "introduce", { get: function() { return document.getElementById('introduce').innerHTML; }, set: function(introduce) { document.getElementById('introduce').innerHTML = introduce; }}) 三、数据M12userInfo.nickName = "xxx";userInfo.introduce = "我是xxx,我来自云南,..."