<template>
<div id="app">
<input type="text" v-model='msg'>
<div>
<p>{{msg}}</p>
</div>
</div>
</template> <script> class Observer{
static _observe(obj){
for(var key in obj){
//遍历obj对象 var value =obj[key];
if(typeof value ==='object'){
//如果值还是对象,则遍历处理
Observer._observe(value);
}
console.log("========def" ,key);
Object.defineProperty(obj, key, {
enumerable: true,
configurable: true,
set: function (newValue) {
if( value !== newValue ) {
var value = newValue;
console.log('setter:' + newValue);
}
},
get: function () {
console.log('getter:' +value);
return value;
}
}); }
}
} class VM{
constructor(options){
this.$options = options;
this._obverse(this.$options.data);
return Object.assign({data:this.$options.data}, this.$options.methods );
}
_obverse(data) {
return Observer._observe(data);
} }
var vm = new VM({
el: '#app',
data: {
msg:'hello'
},
methods: {
hello:function(){
console.log("hello");
}
}
}) vm.data.msg = "wwww"
var x = vm.data.msg;
vm.hello(); </script>

最新文章

  1. 在xampp中配置dvwa
  2. SqlServer字段说明查询
  3. IOS5中的Safari不兼容Javascript中的Date问题,做下笔录吧!奶奶的,折腾我半天!
  4. 转 如何理解 重要性采样(importance sampling)
  5. linux 问答
  6. require.js入门指南(二)
  7. NetMQ(ZeroMQ)Client =&gt; Server =&gt; Client 模式的实现
  8. NTP 服务器配置
  9. 关于IE打印预览内容显示不全的问题解决
  10. Windows Server 架设VPN要点
  11. 导入礼包时,遇到file_get_contents读取的文本,去除空格、换行等的方法
  12. Eclipse目录实解
  13. PDF转图片工具
  14. labview下载地址
  15. PHP实现微信商户支付企业付款到零钱功能代码实例
  16. Zookeeper Ephemeral结点使用心得
  17. linux 二级域名设置
  18. 分享一个shell脚本的坑:grep匹配+wc取值 在脚本执行后的结果与手动执行结果不一致
  19. Java循环中标签的作用(转)
  20. hook进程

热门文章

  1. windows server的应用软件限流QoS
  2. 全链路压测SOP
  3. 头条二面:宕机后,Redis如何实现快速恢复?
  4. vue super flow 多种形状
  5. vue element 可编辑表格行内验证
  6. elasticSearch(五)--排序
  7. Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test (default-test) on project
  8. pat乙级1012数字分类
  9. linux 服务器 重命名
  10. HOW TO RENDER TO A TEXTURE ARRAY IN UNITY